public function transform($entities)
    {
        if (is_null($entities) || count($entities) === 0) {
            return [];
        }

        $data = [];
        $accessor = PropertyAccess::createPropertyAccessor();

        foreach ($entities as $entity) {
            $text = is_null($this->textProperty)
                ? (string)$entity
                : $accessor->getValue($entity, $this->textProperty);
            $data[$accessor->getValue($entity, $this->primaryKey)] = [
                'text' => $text
            ];
        }

        return $data;
    }
public function transform($entities)
    {
        if (is_null($entities) || count($entities) === 0) {
            return [];
        }

        $data = [];
        $accessor = PropertyAccess::createPropertyAccessor();

        foreach ($entities as $entity) {
            $text = is_null($this->textProperty)
                ? (string)$entity
                : $accessor->getValue($entity, $this->textProperty);
            $data[$accessor->getValue($entity, $this->primaryKey)] = [
                'text' => $text
            ];
        }

        return $data;
    }
public function transform ( $ entities ) { if ( is_null ( $ entities ) || count ( $ entities ) === 0 ) { return [ ] ; } $ data = [ ] ; $ accessor = PropertyAccess :: createPropertyAccessor ( ) ; foreach ( $ entities as $ entity ) { $ text = is_null ( $ this -> textProperty ) ? ( string ) $ entity : $ accessor -> getValue ( $ entity , $ this -> textProperty ) ; $ data [ $ accessor -> getValue ( $ entity , $ this -> primaryKey ) ] = [ 'text' => $ text ] ; } return $ data ; }
Transform initial entities to array
@param mixed $entities
@return array
Transform initial entities to array