src/Admin/Mixin/AdminSearchableTrait.php
protected function generateAdminSearchable()
    {
        $translator = $this->translator();
        $languages  = $translator->availableLocales();

        $searchKeywords = [];

        $searchableProperties = $this->metadata()->get('admin.search.properties');

        foreach ($searchableProperties as $propIdent => $searchData) {
            $property = $this->property($propIdent);
            $objValue    = $this[$propIdent];

            if (empty($objValue)) {
                continue;
            }

            if ($property instanceof ObjectProperty) {
                if (empty($searchData['properties'])) {
                    continue;
                }

                $searchProps  = $searchData['properties'];
                $fillKeywords = function ($relObj) use (&$searchKeywords, $searchProps, $translator, $languages) {
                    foreach ($searchProps as $searchProp) {
                        foreach ($languages as $lang) {
                            $relValue = $relObj->get($searchProp);
                            $searchKeywords[$lang][] = $translator->translate($relValue, [], null, $lang);
                        }
                    }
                };

                $relObjType = $property->objType();
                if ($property->multiple()) {
                    if (!count($objValue)) {
                        continue;
                    }

                    $relObjIds = implode($property->multipleSeparator(), $objValue);
                    $this->collectionLoader()
                         ->setModel($relObjType)
                         ->addFilter([
                            'condition' => sprintf('FIND_IN_SET(objTable.id, "%s")', $relObjIds),
                         ])
                         ->setCallback($fillKeywords)
                         ->load();
                } else {
                    $relObj = $this->modelFactory()->create($relObjType)->load($objValue);
                    $fillKeywords($relObj);
                }
            } else {
                foreach ($languages as $lang) {
                    $objValue = $property->parseVal($objValue);
                    $searchKeywords[$lang][] = $translator->translate($objValue, [], null, $lang);
                }
            }
        }

        $this->setAdminSearchKeywords($searchKeywords);
    }
protected function generateAdminSearchable()
    {
        $translator = $this->translator();
        $languages  = $translator->availableLocales();

        $searchKeywords = [];

        $searchableProperties = $this->metadata()->get('admin.search.properties');

        foreach ($searchableProperties as $propIdent => $searchData) {
            $property = $this->property($propIdent);
            $objValue    = $this[$propIdent];

            if (empty($objValue)) {
                continue;
            }

            if ($property instanceof ObjectProperty) {
                if (empty($searchData['properties'])) {
                    continue;
                }

                $searchProps  = $searchData['properties'];
                $fillKeywords = function ($relObj) use (&$searchKeywords, $searchProps, $translator, $languages) {
                    foreach ($searchProps as $searchProp) {
                        foreach ($languages as $lang) {
                            $relValue = $relObj->get($searchProp);
                            $searchKeywords[$lang][] = $translator->translate($relValue, [], null, $lang);
                        }
                    }
                };

                $relObjType = $property->objType();
                if ($property->multiple()) {
                    if (!count($objValue)) {
                        continue;
                    }

                    $relObjIds = implode($property->multipleSeparator(), $objValue);
                    $this->collectionLoader()
                         ->setModel($relObjType)
                         ->addFilter([
                            'condition' => sprintf('FIND_IN_SET(objTable.id, "%s")', $relObjIds),
                         ])
                         ->setCallback($fillKeywords)
                         ->load();
                } else {
                    $relObj = $this->modelFactory()->create($relObjType)->load($objValue);
                    $fillKeywords($relObj);
                }
            } else {
                foreach ($languages as $lang) {
                    $objValue = $property->parseVal($objValue);
                    $searchKeywords[$lang][] = $translator->translate($objValue, [], null, $lang);
                }
            }
        }

        $this->setAdminSearchKeywords($searchKeywords);
    }
protected function generateAdminSearchable ( ) { $ translator = $ this -> translator ( ) ; $ languages = $ translator -> availableLocales ( ) ; $ searchKeywords = [ ] ; $ searchableProperties = $ this -> metadata ( ) -> get ( 'admin.search.properties' ) ; foreach ( $ searchableProperties as $ propIdent => $ searchData ) { $ property = $ this -> property ( $ propIdent ) ; $ objValue = $ this [ $ propIdent ] ; if ( empty ( $ objValue ) ) { continue ; } if ( $ property instanceof ObjectProperty ) { if ( empty ( $ searchData [ 'properties' ] ) ) { continue ; } $ searchProps = $ searchData [ 'properties' ] ; $ fillKeywords = function ( $ relObj ) use ( & $ searchKeywords , $ searchProps , $ translator , $ languages ) { foreach ( $ searchProps as $ searchProp ) { foreach ( $ languages as $ lang ) { $ relValue = $ relObj -> get ( $ searchProp ) ; $ searchKeywords [ $ lang ] [ ] = $ translator -> translate ( $ relValue , [ ] , null , $ lang ) ; } } } ; $ relObjType = $ property -> objType ( ) ; if ( $ property -> multiple ( ) ) { if ( ! count ( $ objValue ) ) { continue ; } $ relObjIds = implode ( $ property -> multipleSeparator ( ) , $ objValue ) ; $ this -> collectionLoader ( ) -> setModel ( $ relObjType ) -> addFilter ( [ 'condition' => sprintf ( 'FIND_IN_SET(objTable.id, "%s")' , $ relObjIds ) , ] ) -> setCallback ( $ fillKeywords ) -> load ( ) ; } else { $ relObj = $ this -> modelFactory ( ) -> create ( $ relObjType ) -> load ( $ objValue ) ; $ fillKeywords ( $ relObj ) ; } } else { foreach ( $ languages as $ lang ) { $ objValue = $ property -> parseVal ( $ objValue ) ; $ searchKeywords [ $ lang ] [ ] = $ translator -> translate ( $ objValue , [ ] , null , $ lang ) ; } } } $ this -> setAdminSearchKeywords ( $ searchKeywords ) ; }
Generate this object's search keywords for the Charcoal Admin.

@return void
Generate this object s search keywords for the Charcoal Admin .