Пример #1
0
 /**
  * Loads the resource and return the result.
  *
  * @param mixed  $resource
  * @param string $type
  *
  * @return EmoticonCollection
  */
 public function load($resource, $type = null)
 {
     $path = $this->locator->locate($resource);
     $config = $this->loadFile($path);
     $collection = new EmoticonCollection();
     $collection->addResource(new FileResource($path));
     // empty file
     if (null === $config) {
         return $collection;
     }
     $this->parseImports($collection, $config, $resource);
     $this->parseEmoticons($collection, $config);
     return $collection;
 }
Пример #2
0
 /**
  * Gets the EmoticonCollection instance associated with this EmoticonHook.
  *
  * @return EmoticonCollection A EmoticonCollection instance
  */
 public function getEmoticonCollection()
 {
     if (null !== $this->collection) {
         return $this->collection;
     }
     $this->collection = new EmoticonCollection();
     if (null === $this->_parser) {
         // Gets default decoda emoticons ($this->_emoticons)
         parent::setParser(new Decoda());
     }
     // Convert a default decoda emoticons array to an EmoticonCollection
     $collection = new EmoticonCollection();
     foreach ($this->_emoticons as $name => $smilies) {
         $emoticon = new Emoticon();
         foreach ($smilies as $smiley) {
             $emoticon->setSmiley($smiley);
         }
         $collection->add($name, $emoticon);
     }
     foreach ($this->getParser()->getPaths() as $path) {
         if (!file_exists($path . '/emoticons.json')) {
             continue;
         }
         $collection->addResource(new FileResource($path . '/emoticons.json'));
     }
     $this->collection->addCollection($collection);
     if (null !== $this->options['resource']) {
         $subCollection = $this->loader->load($this->options['resource'], $this->options['resource_type']);
         $this->collection->addCollection($subCollection);
     }
     $this->resolveParameters($this->collection);
     return $this->collection;
 }