public function createTagRelation($tag)
    {
        //filtrowanie tagu
        $filteredTag = (new \Mmi\Filter\Input)->filter($tag);

        //kreacja tagu jeśli brak
        if (null === $tagRecord = (new CmsTagQuery)
            ->whereTag()->equals($filteredTag)
            ->findFirst()) {
            $tagRecord = new CmsTagRecord;
            $tagRecord->tag = $filteredTag;
            $tagRecord->save();
        }
        //znaleziona relacja - nic do zrobienia
        if (null !== (new CmsTagRelationQuery)
                ->whereCmsTagId()->equals($tagRecord->id)
                ->andFieldObject()->equals($this->_object)
                ->andFieldObjectId()->equals($this->_objectId)
                ->findFirst()) {
            return;
        }
        //tworzenie relacji
        $newRelationRecord = new CmsTagRelationRecord;
        $newRelationRecord->cmsTagId = $tagRecord->id;
        $newRelationRecord->object = $this->_object;
        $newRelationRecord->objectId = $this->_objectId;

        //zapis
        $newRelationRecord->save();
    }
public function createTagRelation($tag)
    {
        //filtrowanie tagu
        $filteredTag = (new \Mmi\Filter\Input)->filter($tag);

        //kreacja tagu jeśli brak
        if (null === $tagRecord = (new CmsTagQuery)
            ->whereTag()->equals($filteredTag)
            ->findFirst()) {
            $tagRecord = new CmsTagRecord;
            $tagRecord->tag = $filteredTag;
            $tagRecord->save();
        }
        //znaleziona relacja - nic do zrobienia
        if (null !== (new CmsTagRelationQuery)
                ->whereCmsTagId()->equals($tagRecord->id)
                ->andFieldObject()->equals($this->_object)
                ->andFieldObjectId()->equals($this->_objectId)
                ->findFirst()) {
            return;
        }
        //tworzenie relacji
        $newRelationRecord = new CmsTagRelationRecord;
        $newRelationRecord->cmsTagId = $tagRecord->id;
        $newRelationRecord->object = $this->_object;
        $newRelationRecord->objectId = $this->_objectId;

        //zapis
        $newRelationRecord->save();
    }
public function createTagRelation ( $ tag ) { //filtrowanie tagu $ filteredTag = ( new \ Mmi \ Filter \ Input ) -> filter ( $ tag ) ; //kreacja tagu jeśli brak if ( null === $ tagRecord = ( new CmsTagQuery ) -> whereTag ( ) -> equals ( $ filteredTag ) -> findFirst ( ) ) { $ tagRecord = new CmsTagRecord ; $ tagRecord -> tag = $ filteredTag ; $ tagRecord -> save ( ) ; } //znaleziona relacja - nic do zrobienia if ( null !== ( new CmsTagRelationQuery ) -> whereCmsTagId ( ) -> equals ( $ tagRecord -> id ) -> andFieldObject ( ) -> equals ( $ this -> _object ) -> andFieldObjectId ( ) -> equals ( $ this -> _objectId ) -> findFirst ( ) ) { return ; } //tworzenie relacji $ newRelationRecord = new CmsTagRelationRecord ; $ newRelationRecord -> cmsTagId = $ tagRecord -> id ; $ newRelationRecord -> object = $ this -> _object ; $ newRelationRecord -> objectId = $ this -> _objectId ; //zapis $ newRelationRecord -> save ( ) ; }
Taguje tagiem po nazwie
@param string $tag tag
Taguje tagiem po nazwie