/** * @return array all elements as an array */ public function toArray() { /** * Array keys chnges during live cycle of queue. Using array_values() to * make sure that array will be indexed starting 0. */ return array_values(parent::toArray()); }
/** * @return ResourceCollection */ protected function createPlain() { $entities = $this->entities->toArray() ?: []; $metadata = $this->mineMetadata($entities); // El método map() sólo puede generar colecciones del mismo tipo. $resources = array_map([$this, 'createResource'], $entities); return new ResourceCollection($resources, $metadata); }
public function getRoles() { if (!$this->roles->count()) { return array(parent::ROLE_DEFAULT); } $roles = $this->roles->toArray(); foreach ($this->getGroups() as $group) { $roles = array_merge($roles, $group->getRoles()); } foreach ($roles as $k => $role) { /* * Ensure String[] to prevent bad unserialized UsernamePasswordToken with for instance * UPT#roles:{Role('ROLE_USER'), 'ROLE_USER'} which ends in Error: Call to a member * function getRole() on a non-object */ $roles[$k] = $role instanceof RoleInterface ? $role->getRole() : (string) $role; } return array_flip(array_flip($roles)); }
/** {@inheritDoc} */ public function toArray() { $this->initialize(); return $this->collection->toArray(); }