Knp\Bundle\KnpBundlesBundle\Entity\Bundle::getDescription PHP Method

getDescription() public method

Get description
public getDescription ( null | integer $cutAfter = null ) : string
$cutAfter null | integer
return string
    public function getDescription($cutAfter = null)
    {
        if (null === $cutAfter) {
            return $this->description;
        }
        return $this->description ? substr($this->description, 0, $cutAfter) : null;
    }

Usage Example

Example #1
0
 /**
  * Populates document with bundle data.
  *
  * @param \Solarium_Document_ReadWrite $document
  * @param Bundle                       $bundle
  * @param \Solarium_Query_Helper       $helper
  */
 private function updateDocumentFromBundle(\Solarium_Document_ReadWrite $document, Bundle $bundle, \Solarium_Query_Helper $helper)
 {
     $document->setField('id', $bundle->getId());
     $document->setField('name', $bundle->getName());
     $document->setField('ownerName', $bundle->getOwnerName());
     $document->setField('ownerType', $bundle->getOwnerType());
     $document->setField('fullName', $bundle->getFullName());
     $document->setField('description', $bundle->getDescription());
     $document->setField('readme', $bundle->getReadme());
     $document->setField('totalScore', $bundle->getScore());
     $document->setField('state', $bundle->getState());
     $document->setField('avatarUrl', $bundle->getOwner()->getAvatarUrl());
     $document->setField('lastCommitAt', $helper->formatDate(clone $bundle->getLastCommitAt()));
     $document->setField('lastTweetedAt', null !== $bundle->getLastTweetedAt() ? $helper->formatDate($bundle->getLastTweetedAt()) : null);
     $keywords = array();
     foreach ($bundle->getKeywords() as $keyword) {
         $keywords[mb_strtolower($keyword->getValue(), 'UTF-8')] = true;
     }
     $document->setField('keywords', array_keys($keywords));
 }