src/Alchemy/Component/Cerberus/Model/Base/Permission.php
public function getRoles(Criteria $criteria = null, ConnectionInterface $con = null)
    {
        $partial = $this->collRolesPartial && !$this->isNew();
        if (null === $this->collRoles || null !== $criteria || $partial) {
            if ($this->isNew()) {
                // return empty collection
                if (null === $this->collRoles) {
                    $this->initRoles();
                }
            } else {

                $query = ChildRoleQuery::create(null, $criteria)
                    ->filterByPermission($this);
                $collRoles = $query->find($con);
                if (null !== $criteria) {
                    return $collRoles;
                }

                if ($partial && $this->collRoles) {
                    //make sure that already added objects gets added to the list of the database.
                    foreach ($this->collRoles as $obj) {
                        if (!$collRoles->contains($obj)) {
                            $collRoles[] = $obj;
                        }
                    }
                }

                $this->collRoles = $collRoles;
                $this->collRolesPartial = false;
            }
        }

        return $this->collRoles;
    }
public function getRoles(Criteria $criteria = null, ConnectionInterface $con = null)
    {
        $partial = $this->collRolesPartial && !$this->isNew();
        if (null === $this->collRoles || null !== $criteria || $partial) {
            if ($this->isNew()) {
                // return empty collection
                if (null === $this->collRoles) {
                    $this->initRoles();
                }
            } else {

                $query = ChildRoleQuery::create(null, $criteria)
                    ->filterByPermission($this);
                $collRoles = $query->find($con);
                if (null !== $criteria) {
                    return $collRoles;
                }

                if ($partial && $this->collRoles) {
                    //make sure that already added objects gets added to the list of the database.
                    foreach ($this->collRoles as $obj) {
                        if (!$collRoles->contains($obj)) {
                            $collRoles[] = $obj;
                        }
                    }
                }

                $this->collRoles = $collRoles;
                $this->collRolesPartial = false;
            }
        }

        return $this->collRoles;
    }
public function getRoles ( Criteria $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collRolesPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collRoles || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) ) { // return empty collection if ( null === $ this -> collRoles ) { $ this -> initRoles ( ) ; } } else { $ query = ChildRoleQuery :: create ( null , $ criteria ) -> filterByPermission ( $ this ) ; $ collRoles = $ query -> find ( $ con ) ; if ( null !== $ criteria ) { return $ collRoles ; } if ( $ partial && $ this -> collRoles ) { //make sure that already added objects gets added to the list of the database. foreach ( $ this -> collRoles as $ obj ) { if ( ! $ collRoles -> contains ( $ obj ) ) { $ collRoles [ ] = $ obj ; } } } $ this -> collRoles = $ collRoles ; $ this -> collRolesPartial = false ; } } return $ this -> collRoles ; }
Gets a collection of ChildRole objects related by a many-to-many relationship
to the current object by way of the role_permission cross-reference table.

If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this ChildPermission is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.

@param      Criteria $criteria Optional query object to filter the query
@param      ConnectionInterface $con Optional connection object

@return ObjectCollection|ChildRole[] List of ChildRole objects
Gets a collection of ChildRole objects related by a many - to - many relationship to the current object by way of the role_permission cross - reference table .