plugin/favourite/Manager/FavouriteManager.php
public function createFavourite(User $user, ResourceNode $resourceNode)
    {
        $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]);

        if (empty($favourite)) {
            $favourite = new Favourite();
            $favourite->setUser($user);
            $favourite->setResourceNode($resourceNode);
            $this->om->persist($favourite);
            $this->om->flush();
        }
    }
public function createFavourite(User $user, ResourceNode $resourceNode)
    {
        $favourite = $this->repo->findOneBy(['user' => $user, 'resourceNode' => $resourceNode]);

        if (empty($favourite)) {
            $favourite = new Favourite();
            $favourite->setUser($user);
            $favourite->setResourceNode($resourceNode);
            $this->om->persist($favourite);
            $this->om->flush();
        }
    }
public function createFavourite ( User $ user , ResourceNode $ resourceNode ) { $ favourite = $ this -> repo -> findOneBy ( [ 'user' => $ user , 'resourceNode' => $ resourceNode ] ) ; if ( empty ( $ favourite ) ) { $ favourite = new Favourite ( ) ; $ favourite -> setUser ( $ user ) ; $ favourite -> setResourceNode ( $ resourceNode ) ; $ this -> om -> persist ( $ favourite ) ; $ this -> om -> flush ( ) ; } }
Creates a favourite for given user and resource.

@param User         $user
@param ResourceNode $resourceNode
Creates a favourite for given user and resource .