src/Service/Refiller.php
public function search(Item $item, $field)
    {
        // can refill from source. not need search
        if ($url = $this->getSourceForFill($item)) {
            return [
                new ItemRefiller(
                    $item->getName(),
                    ['url' => $url],
                    $url,
                    $item->getCover(),
                    $item->getSummary()
                ),
            ];
        }

        // get name for search
        if (!($name = $item->getName())) {
            foreach ($item->getNames() as $name) {
                if ($name) {
                    break;
                }
            }
        }

        $result = [];
        // do search
        if ($name) {
            $result = $this->search->search(['name' => $name]);
            /* @var $item \AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Search\Item */
            foreach ($result as $key => $item) {
                parse_str(parse_url($item->getLink(), PHP_URL_QUERY), $query);
                $link = array_values($query)[0]['url'];
                $result[$key] = new ItemRefiller(
                    $item->getName(),
                    ['url' => $link],
                    $link,
                    $item->getImage(),
                    $item->getDescription()
                );
            }
        }

        return $result;
    }
public function search(Item $item, $field)
    {
        // can refill from source. not need search
        if ($url = $this->getSourceForFill($item)) {
            return [
                new ItemRefiller(
                    $item->getName(),
                    ['url' => $url],
                    $url,
                    $item->getCover(),
                    $item->getSummary()
                ),
            ];
        }

        // get name for search
        if (!($name = $item->getName())) {
            foreach ($item->getNames() as $name) {
                if ($name) {
                    break;
                }
            }
        }

        $result = [];
        // do search
        if ($name) {
            $result = $this->search->search(['name' => $name]);
            /* @var $item \AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Search\Item */
            foreach ($result as $key => $item) {
                parse_str(parse_url($item->getLink(), PHP_URL_QUERY), $query);
                $link = array_values($query)[0]['url'];
                $result[$key] = new ItemRefiller(
                    $item->getName(),
                    ['url' => $link],
                    $link,
                    $item->getImage(),
                    $item->getDescription()
                );
            }
        }

        return $result;
    }
public function search ( Item $ item , $ field ) { // can refill from source. not need search if ( $ url = $ this -> getSourceForFill ( $ item ) ) { return [ new ItemRefiller ( $ item -> getName ( ) , [ 'url' => $ url ] , $ url , $ item -> getCover ( ) , $ item -> getSummary ( ) ) , ] ; } // get name for search if ( ! ( $ name = $ item -> getName ( ) ) ) { foreach ( $ item -> getNames ( ) as $ name ) { if ( $ name ) { break ; } } } $ result = [ ] ; // do search if ( $ name ) { $ result = $ this -> search -> search ( [ 'name' => $ name ] ) ; /* @var $item \AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Search\Item */ foreach ( $ result as $ key => $ item ) { parse_str ( parse_url ( $ item -> getLink ( ) , PHP_URL_QUERY ) , $ query ) ; $ link = array_values ( $ query ) [ 0 ] [ 'url' ] ; $ result [ $ key ] = new ItemRefiller ( $ item -> getName ( ) , [ 'url' => $ link ] , $ link , $ item -> getImage ( ) , $ item -> getDescription ( ) ) ; } } return $ result ; }
Search items for refill.

@param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item
@param string                                    $field

@return array [\AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Refiller\Item]
Search items for refill .