本文整理汇总了PHP中Doctrine\Common\Collections\ArrayCollection::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayCollection::toArray方法的具体用法?PHP ArrayCollection::toArray怎么用?PHP ArrayCollection::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\ArrayCollection
的用法示例。
在下文中一共展示了ArrayCollection::toArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getParameters
/**
* Get parameters.
*
* @return array
*/
public function getParameters()
{
if (!$this->parameters instanceof ArrayCollection) {
return [];
}
return $this->parameters->toArray();
}
示例2: __toString
/**
* Set comma state on oxford candidate word and
* implode words back together
*
* @return string
*/
public function __toString()
{
$this->getOxfordItems()->map(function (Word $word) {
$word->setComma($this->getOxford());
});
return implode(' ', $this->words->toArray());
}
示例3: toArray
public function toArray()
{
if (null === $this->entries) {
$this->__load___();
}
return $this->entries->toArray();
}
示例4: toArray
/**
* Returns fields as an array
*
* @return array
*/
public function toArray()
{
/**
* @todo: DO we bother that we have objects inside
*/
return $this->collection->toArray();
}
示例5: getDescendants
function getDescendants($result = null)
{
if ($result == null) {
$result = array();
}
$result = array_merge($result, $this->entries->toArray());
foreach ($this->children as $c) {
$result = $c->getDescendants($result);
}
return $result;
}
示例6: findBy
/**
* @param array $criteria
*
* @param array $orderBy
* @param null $limit
* @param null $offset
*
* @return mixed
*/
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
{
return array_filter($this->entities->toArray(), function ($entity) use($criteria) {
$conditions = [];
foreach ($criteria as $key => $value) {
$conditions[] = $entity->{$key}() == $value;
}
return array_reduce($conditions, function ($carry, $condition) {
return $carry && $condition;
}, true);
});
}
示例7: getRoleById
public function getRoleById($roleId)
{
$roles = $this->roles->toArray();
foreach ($this->getGroups() as $group) {
$roles = array_merge($roles, $group->getRoles());
}
foreach ($roles as $r) {
if ($r->getId() == $roleId) {
return true;
}
}
return false;
}
示例8: getStandings
/**
* @return Team[]
*/
public function getStandings()
{
/** @var Team[] $teams */
$teams = $this->teams->toArray();
$points = array();
$goalsDifference = array();
$goalsFor = array();
foreach ($teams as $k => $team) {
$points[$k] = $team->getPoints();
$goalsDifference[$k] = $team->getGoalsDifference();
$goalsFor[$k] = $team->getGoalsFor();
}
array_multisort($points, SORT_DESC, $goalsDifference, SORT_DESC, $goalsFor, SORT_DESC, $teams);
return $teams;
}
示例9: getQBAliasReference
public function getQBAliasReference($class, $attribute = NULL)
{
if (!is_object($class)) {
throw new \Exception("object must be of type object, type %s given.", gettype($class));
}
$class_name = get_class($class);
// get alias of class
$alias = NULL;
foreach ($this->qb_alias_reference->toArray() as $_class => $_alias) {
if (isset($_alias[$class_name])) {
$alias = $_alias[$class_name];
}
}
// if not found
if ($alias === NULL) {
// if empty, set new
if ($this->qb_alias_reference->count() == 0) {
$alias = 'a';
// get last and then count up
} else {
$lastAlias = $this->qb_alias_reference->last();
$alias = ++$lastAlias[key($lastAlias)];
}
// add new
$this->qb_alias_reference->add(array($class_name => $alias));
}
return $attribute === NULL ? $alias : $alias . '.' . $attribute;
}
示例10: getLastSavedDraftRevision
/**
* Return the last draft saved.
*
* @return Revision
*/
public function getLastSavedDraftRevision()
{
if (!empty($this->lastSavedDraft)) {
return $this->lastSavedDraft;
}
$published = $this->publishedRevision;
$staged = $this->stagedRevision;
$arrayCollection = $this->revisions->toArray();
/** @var \Rcm\Entity\Revision $revision */
$revision = end($arrayCollection);
if (empty($revision)) {
return null;
}
$found = false;
while (!$found) {
if (empty($revision)) {
break;
} elseif (!empty($published) && $published->getRevisionId() == $revision->getRevisionId()) {
$found = false;
} elseif (!empty($staged) && $staged->getRevisionId() == $revision->getRevisionId()) {
$found = false;
} elseif ($revision->wasPublished()) {
$found = false;
} else {
$found = true;
}
if (!$found) {
$revision = prev($arrayCollection);
}
}
return $this->lastSavedDraft = $revision;
}
示例11: getOrderedThreads
/**
* Get ordered threads
*
* @return ArrayCollection
*/
public function getOrderedThreads()
{
$threads = $this->threads->toArray();
usort($threads, function (ForumThread $a, ForumThread $b) {
if ($b->getStickied() === true && $a->getStickied() === false) {
return 1;
}
if ($b->getStickied() === false && $a->getStickied() === false) {
if ($b->getPosts()->count() > 0 && $a->getPosts()->count() === 0) {
return 1;
}
if ($b->getPosts()->count() === 0 && $a->getPosts()->count() > 0) {
return -1;
}
if ($b->getPosts()->count() === 0 && $a->getPosts()->count() === 0) {
return 0;
}
if ($b->getPosts()->last()->getDateCreated() > $a->getPosts()->last()->getDateCreated()) {
return 1;
}
if ($b->getPosts()->last()->getDateCreated() < $a->getPosts()->last()->getDateCreated()) {
return -1;
}
}
return 0;
});
return $threads;
}
示例12: setTasks
/**
* @param ArrayCollection $tasks
*
* @return HasTasksInterface
*/
public function setTasks(ArrayCollection $tasks)
{
foreach ($tasks->toArray() as $task) {
$this->addTask($task);
}
return $this;
}
示例13: indexAction
public function indexAction()
{
$user = new User();
$rol = new RolSistema();
$opciones = new ArrayCollection();
//new OpcionSistema();
$user = $this->get('security.context')->getToken()->getUser();
if ($user != 'anon.' && $user->getAuditDeleted() == false) {
$roles = $user->getRols();
if (isset($roles)) {
foreach ($roles as $rol) {
//$opciones = $rol->getOpcionesSistema();
$opciones = new ArrayCollection(array_merge_maintain_keys($opciones->toArray(), $rol->getOpcionesSistema()->toArray()));
}
$peticion = $this->getRequest();
$sesion = $peticion->getSession();
$sesion->set('opciones', $opciones);
return $this->render('MinSalSCABundle:Default:index.html.twig', array('opciones' => $opciones));
}
} else {
if ($user != 'anon.' && $user->getAuditDeleted() == true) {
$this->get('session')->setFlash('notice', 'El usuario "' . $user->getUsername() . '" se encuentra inactivo');
$this->getRequest()->getSession()->set('notice', 'El usuario "' . $user->getUsername() . '" se encuentra inactivo');
return new RedirectResponse($this->generateUrl('fos_user_security_logout'));
//return $this->redirect($this->generateUrl('fos_user_security_logout'));
}
return $this->render('MinSalSCABundle:Default:index.html.twig');
}
}
示例14: loadExistsObjects
/**
* Method for trying load objects via factory
*/
public function loadExistsObjects()
{
$ids = array_column($this->exists->toArray(), 'id');
// Try loading objects by ids via factory
$loaded = $this->factory->load($ids);
if (count($loaded)) {
/** @var TransformableInterface $object */
foreach ($loaded as $object) {
foreach ($this->exists as $item) {
// If object has id equivalent item id then item has new description for that object
if ($object->getId() == $item['id']) {
// Populate object from item description
$this->bindContent($item, $object, $this->map);
// Validate and retrieve errors if exists
if ($errors = $this->validate($object)) {
$this->errors->add(array('item' => $item['number'], 'errors' => $errors));
} else {
$this->result->add($object);
}
// Clean internal "exists" collection for memory free
$this->exists->removeElement($item);
}
}
}
}
// Join not found item in db into "new" collection
foreach ($this->exists as $item) {
$this->new->add($item);
// Clean internal "exists" collection
$this->exists->removeElement($item);
}
}
示例15: addThread
/**
* Add thread to collection
*
* @param Thread $thread
* @return Blacklist
*/
public function addThread($thread)
{
if (!in_array($thread, $this->threads->toArray())) {
$this->threads->add($thread);
}
return $this;
}