/** * Removes an object relation from the aggregation. * * @see KObjectSet::extract() */ public function extract($target) { $relation = $this->_child->find(array($this->_property => $this->_root, $this->_target_property => $target)); if ($relation) { $relation->delete(); } return $relation; }
/** * @return Permission[] */ public function find() { $result = parent::find(); $permissions = array(); foreach ($result as $row) { $permissions[] = new Permission($row); } return $permissions; }
/** * @return Author[] */ public function find() { $result = parent::find(); $authors = array(); foreach ($result as $row) { $authors[] = new Author($row); } return $authors; }
/** * @return Keyword[] */ public function find() { $result = parent::find(); $keywords = array(); foreach ($result as $row) { $keywords[] = new Keyword($row); } return $keywords; }
/** * @return File[] */ public function find() { $result = parent::find(); $files = array(); foreach ($result as $row) { $files[] = new File($row); } return $files; }
/** * @return Url[] */ public function find() { $result = parent::find(); $urls = array(); foreach ($result as $row) { $urls[] = new Url($row); } return $urls; }
/** * @return Type[] */ public function find() { $result = parent::find(); $types = array(); foreach ($result as $row) { $types[] = new Type($row); } return $types; }
function users($id = null) { if (is_null($id)) { $this->e404(); } $this->paginate['Expert']['conditions'] = array('Expert.repository_id' => $id); $this->data = $this->paginate('Expert'); $repo = $this->Repository->find('first', array('conditions' => compact('id'), 'recursive' => -1)); $data = array('current' => 'repositories', 'repo' => $repo, 'menu' => 'menu_admin', 'title' => "Collaborators of '{$repo['Repository']['name']}' Repository", 'cond' => 'owner', 'footnotes' => array('Repository owner (only 1)')); $this->set($data); $this->render('../admin_usuarios/listar'); }
/** * @return Citation[] */ public function find() { $result = parent::find(); $citations = array(); foreach ($result as $row) { $citation = new Citation($row); $repo = new PublicationRepository($this->db); $citation->setCitationPublication($repo->where('id', '=', $citation->getCitationId())->findSingle()); $citations[] = $citation; } return $citations; }
/** * @param bool $full * * @return Role[] */ public function find($full = false) { $result = parent::find(); $roles = array(); foreach ($result as $row) { $role = new Role($row); if ($full === true) { $repo = new PermissionRepository($this->db); $role->setPermissions($repo->where('role_id', '=', $role->getId())->order('name', 'ASC')->find()); } $roles[] = $role; } return $roles; }
/** * @param bool $full * * @return User[] */ public function find($full = false) { $result = parent::find(); $users = array(); foreach ($result as $row) { $user = new User($row); if ($full === true) { $repo = new RoleRepository($this->db); $user->setRoles($repo->where('user_id', '=', $user->getId())->order('name', 'ASC')->find()); $repo = new PermissionRepository($this->db); $user->setPermissions($repo->where('user_id', '=', $user->getId())->order('name', 'ASC')->find()); } $users[] = $user; } return $users; }
/** * * set repository data in session, by id or url, if exists * @param array $data * @return array array( boolean: status, array: data | null) */ function _set_repo($data = array()) { if (empty($data)) { return array(false, null); } if (isset($data['repo_url'])) { $repo = $this->Repository->find('first', array('conditions' => array('Repository.url' => $data['repo_url']), 'recursive' => -1)); } elseif (isset($data['repo_id'])) { $repo = $this->Repository->find('first', array('conditions' => array('Repository.id' => $data['repo_id']), 'recursive' => -1)); } if (!empty($repo)) { $this->setRepositorySession($repo); return array(true, $repo); } else { return array(false, null); } }
/** * @param bool $full * * @return Publication[] */ public function find($full = false) { $result = parent::find(); $publications = array(); foreach ($result as $row) { $publication = new Publication($row); $repo = new AuthorRepository($this->db); $publication->setAuthors($repo->where('publication_id', '=', $publication->getId())->order('priority', 'ASC')->find()); $repo = new FileRepository($this->db); $publication->setFiles($repo->where('publication_id', '=', $publication->getId())->find()); $repo = new UrlRepository($this->db); $publication->setUrls($repo->where('publication_id', '=', $publication->getId())->find()); if ($full === true) { $repo = new KeywordRepository($this->db); $publication->setKeywords($repo->where('publication_id', '=', $publication->getId())->order('name', 'ASC')->find()); } $publications[] = $publication; } return $publications; }
/** * returns current repository data as array * note: if host is localhost, it just reads from the session var * which means to have an expiration time */ function getCurrentRepository() { $repo = null; if (Configure::read('App.subdomains')) { $url = explode('.', $_SERVER['HTTP_HOST'], 3); if (count($url) === 2 or $url[0] === 'www') { $repo = null; } else { $repo = $url[0]; } } elseif ($this->Session->check('Repository.current')) { $repo = $this->Session->read('Repository.current'); } if (!is_null($repo)) { $data = $this->Repository->find('first', array('conditions' => array('Repository.url' => $repo))); if (!is_null($data) && !empty($data)) { return $data; } } return null; }
public function testAutoEagerLoading() { $person = new Person(); // We expect a new person to contain the // relations defined with the ResourceInterface 'unit'. $person = $this->repository->create($person); $this->assertEquals(0, $person->roles->count()); $this->assertEquals(0, $person->children->count()); // Check auto-eager-loading. $homer = $this->repository->find(1); $this->assertEquals(1, $homer->roles->count()); $this->assertEquals(3, $homer->children->count()); $simpsons = $this->repository->all(); $simpsons = json_decode(json_encode($simpsons)); $this->assertEquals(1, count($simpsons[0]->roles)); $this->assertFalse(property_exists($simpsons[0], 'children')); // Check that repository with() method override default settings. $simpsons = $this->repository->with(['roles', 'children'])->all(); $simpsons = json_decode(json_encode($simpsons)); $this->assertEquals(1, count($simpsons[0]->roles)); $this->assertEquals(3, count($simpsons[0]->children)); }
<?php require_once './repository.php'; /** * 跳转通知 */ $orderNumber = $_REQUEST['orderNumber']; //不区分GET/POST $order = Repository::find($orderNumber); if ($order['status'] != 'NOTIFY_CONFIRM') { //订单尚未收到入账通知,应发起主动查询 header('location: ./order-query.php?orderNumber=' . $orderNumber); exit; } //跳转响应完成,开始输出付款完成界面 include_once 'pay-result.html';
<?php require_once './sdk/Hpp.PayService.php'; require_once './sdk/Hpp.Protocol.php'; /** * 处理入账响应 */ //直接读取整个req过来的请求 $rawEventBody = file_get_contents('php://input'); $tradeEvent = new TradeSuccessEvent(PayService::reciveTradeSuccessEvent($rawEventBody)); if ($tradeEvent->isTradeSuccess()) { //TODO: 订单已完成,在这里完成发货逻辑... //存储模拟的订单信息 $order = Repository::find($tradeEvent->getOrderNumber()); $order['status'] = $tradeEvent->getStatus(); Repository::save($tradeEvent->getOrderNumber(), json_encode($order)); }