PHP Class Newscoop\NewscoopBundle\Services\TopicService

Exibir arquivo Open project: sourcefabric/newscoop

Protected Properties

Property Type Description
$dispatcher
$em

Public Methods

Method Description
__construct ( EntityManager $em, EventDispatcher $dispatcher )
addTopicToArticle ( Topic $topic, Article $article ) : boolean Adds topic to the article.
checkTopicName ( string $locale, string $title ) : boolean Check if topic name already exists by given locale.
countArticleTopicsBy ( array $criteria = [] ) : integer Count article topics by given criteria.
countBy ( array $criteria = [] ) : integer Count topics by given criteria.
deleteTopic ( Topic $topic ) : boolean Deletes the topic. If topic is attached to any article it is first detached and deleted.
getMultiOptions ( ) : array Get options for forms.
getReadablePath ( Topic $topic, string | null $locale = null ) : string Wrapper method for getting readable topic path.
getTopicBy ( string $string, string | null $locale = null ) : Topic | null Gets the topic by id, its title or title combined with the language and language code.
getTopicByFullName ( string $fullName ) : Topic | null Returns a topic object identified by the full name in the format topic_name:language_code.
getTopicByFullNameAsArray ( string $fullName ) : array Returns a topic as an array identified by the full name in the format topic_name:language_code.
isAttached ( string | integer $topicId, boolean $attachedCount = false ) : boolean | array Checks if topic is attached to any article.
isFollowed ( string | integer $topicId ) : boolean | array Checks if topic is attached to any article.
removeTopicFromAllArticles ( string | integer $topicId ) : boolean Removes topic from all articles it is attached to.
removeTopicFromAllUsers ( string | integer $topicId ) : boolean Removes topic from all users it is followed by.
removeTopicFromArticle ( Topic $topic, Article $article ) : boolean Removes topic from the article.
reorderRootNodes ( array $rootNodes, array $order = [] ) : boolean Reorder root topics.
saveNewTopic ( Topic $node, string | null $locale = null ) : boolean Saves new topic. Possibility to overwrite AUTO strategy (set custom ids).
saveTopicPosition ( Topic $node, array $params ) : boolean Saves topic position when it was dragged and dropped.
setTranslatableHint ( Doctrine\ORM\Query $query, string $locale = null ) : Doctrine\ORM\Query Wrapper method for setting translatable hint.

Protected Methods

Method Description
attachTopicToArticle ( Topic $topic, Article $article ) : boolean Adds topic to the article.
detachTopicFromArticle ( Topic $topic, Article $article ) : boolean Removes topic from the article.
getArticleTopicRepository ( ) : Newscoop\Entity\Repository\ArticleTopicRepository Gets article topic Repository.
getTopicRepository ( ) : Newscoop\NewscoopBundle\Entity\Repository\TopicRepository Gets Topic Repository.

Private Methods

Method Description
extractNameAndLanguage ( $fullName )
getLogArray ( Topic $topic, Article $article )

Method Details

__construct() public method

public __construct ( EntityManager $em, EventDispatcher $dispatcher )
$em Doctrine\ORM\EntityManager
$dispatcher EventDispatcher

addTopicToArticle() public method

Adds topic to the article.
public addTopicToArticle ( Topic $topic, Article $article ) : boolean
$topic Newscoop\NewscoopBundle\Entity\Topic Topic object
$article Newscoop\Entity\Article Article object
return boolean

attachTopicToArticle() protected method

Adds topic to the article.
protected attachTopicToArticle ( Topic $topic, Article $article ) : boolean
$topic Newscoop\NewscoopBundle\Entity\Topic Topic object
$article Newscoop\Entity\Article Article object
return boolean

checkTopicName() public method

Check if topic name already exists by given locale.
public checkTopicName ( string $locale, string $title ) : boolean
$locale string Locale
$title string Topic name
return boolean

countArticleTopicsBy() public method

Count article topics by given criteria.
public countArticleTopicsBy ( array $criteria = [] ) : integer
$criteria array
return integer

countBy() public method

Count topics by given criteria.
public countBy ( array $criteria = [] ) : integer
$criteria array
return integer

deleteTopic() public method

Deletes the topic. If topic is attached to any article it is first detached and deleted.
public deleteTopic ( Topic $topic ) : boolean
$topic Newscoop\NewscoopBundle\Entity\Topic Topic
return boolean

detachTopicFromArticle() protected method

Removes topic from the article.
protected detachTopicFromArticle ( Topic $topic, Article $article ) : boolean
$topic Newscoop\NewscoopBundle\Entity\Topic Topic object
$article Newscoop\Entity\Article Article object
return boolean

getArticleTopicRepository() protected method

Gets article topic Repository.
protected getArticleTopicRepository ( ) : Newscoop\Entity\Repository\ArticleTopicRepository
return Newscoop\Entity\Repository\ArticleTopicRepository

getMultiOptions() public method

Get options for forms.
public getMultiOptions ( ) : array
return array

getReadablePath() public method

Wrapper method for getting readable topic path.
public getReadablePath ( Topic $topic, string | null $locale = null ) : string
$topic Newscoop\NewscoopBundle\Entity\Topic Topic object
$locale string | null Locale e.g. "en"
return string Topic's readable path

getTopicBy() public method

$string parameter value can be: "test", 20, "test:en".
public getTopicBy ( string $string, string | null $locale = null ) : Topic | null
$string string Topic search phrase
$locale string | null Locale
return Newscoop\NewscoopBundle\Entity\Topic | null

getTopicByFullName() public method

Returns a topic object identified by the full name in the format topic_name:language_code.
public getTopicByFullName ( string $fullName ) : Topic | null
$fullName string Topic's full name
return Newscoop\NewscoopBundle\Entity\Topic | null object

getTopicByFullNameAsArray() public method

Returns a topic as an array identified by the full name in the format topic_name:language_code.
public getTopicByFullNameAsArray ( string $fullName ) : array
$fullName string Topic's full name
return array

getTopicRepository() protected method

Gets Topic Repository.
protected getTopicRepository ( ) : Newscoop\NewscoopBundle\Entity\Repository\TopicRepository
return Newscoop\NewscoopBundle\Entity\Repository\TopicRepository

isAttached() public method

If $attachedCount is set to yes, returns an array with the number of topics attached to articles, else returns boolean. By default set to false.
public isAttached ( string | integer $topicId, boolean $attachedCount = false ) : boolean | array
$topicId string | integer Topic id
$attachedCount boolean Switch to include/exclude number of topics
return boolean | array

isFollowed() public method

If $attachedCount is set to yes, returns an array with the number of topics attached to articles, else returns boolean. By default set to false.
public isFollowed ( string | integer $topicId ) : boolean | array
$topicId string | integer Topic id
return boolean | array

removeTopicFromAllArticles() public method

Removes topic from all articles it is attached to.
public removeTopicFromAllArticles ( string | integer $topicId ) : boolean
$topicId string | integer Topic id
return boolean

removeTopicFromAllUsers() public method

Removes topic from all users it is followed by.
public removeTopicFromAllUsers ( string | integer $topicId ) : boolean
$topicId string | integer Topic id
return boolean

removeTopicFromArticle() public method

Removes topic from the article.
public removeTopicFromArticle ( Topic $topic, Article $article ) : boolean
$topic Newscoop\NewscoopBundle\Entity\Topic Topic object
$article Newscoop\Entity\Article Article object
return boolean

reorderRootNodes() public method

Reorder root topics.
public reorderRootNodes ( array $rootNodes, array $order = [] ) : boolean
$rootNodes array Root topics
$order array Topics ids in order
return boolean

saveNewTopic() public method

Saves new topic. Possibility to overwrite AUTO strategy (set custom ids).
public saveNewTopic ( Topic $node, string | null $locale = null ) : boolean
$node Newscoop\NewscoopBundle\Entity\Topic Topic object
$locale string | null Language code
return boolean

saveTopicPosition() public method

Saves topic position when it was dragged and dropped.
public saveTopicPosition ( Topic $node, array $params ) : boolean
$node Newscoop\NewscoopBundle\Entity\Topic Dragged topic object
$params array Parameters with positions
return boolean

setTranslatableHint() public method

When for instance getting topic with German name $locale should be set to "de".
public setTranslatableHint ( Doctrine\ORM\Query $query, string $locale = null ) : Doctrine\ORM\Query
$query Doctrine\ORM\Query Query object
$locale string Locale
return Doctrine\ORM\Query

Property Details

$dispatcher protected_oe property

protected $dispatcher

$em protected_oe property

protected $em