Пример #1
0
 public function update(Entity $entity)
 {
     $group = $entity->getId();
     $this->verifyGroup($group);
     $config = \Kohana::$config->load($group);
     $immutable = $entity->getImmutable();
     foreach ($entity->getChanged() as $key => $val) {
         if (!in_array($key, $immutable)) {
             $config->set($key, $val);
         }
     }
 }
Пример #2
0
 function it_does_interact_with_the_repository_and_authenticator($repo, $authenticator, $format, Entity $user)
 {
     $email = '*****@*****.**';
     $password = '******';
     $this->setIdentifiers(compact('email', 'password'));
     $user->getId()->willReturn(1);
     $user->password = '******';
     $repo->getByEmail($email)->willReturn($user);
     $authenticator->checkPassword($password, $user->password)->willReturn(true);
     $formatted = ['email' => '*****@*****.**', 'password' => 'hash'];
     $format->__invoke($user)->willReturn($formatted);
     $this->interact()->shouldReturn($formatted);
 }
Пример #3
0
 /**
  * Verifies that a given entity has been loaded, by checking that the "id"
  * property is not empty.
  * @param  Entity  $entity
  * @param  Mixed   $lookup
  * @return Entity
  * @throws NotFoundException
  */
 protected function verifyEntityLoaded(Entity $entity, $lookup)
 {
     if (!$entity->getId()) {
         if (is_array($lookup)) {
             $arr = [];
             foreach ($lookup as $key => $val) {
                 $arr[] = "{$key}: {$val}";
             }
             $lookup_string = implode(', ', $arr);
         } else {
             $lookup_string = $lookup;
         }
         throw new NotFoundException(sprintf('Could not locate any %s matching [%s]', $entity->getResource(), $lookup_string));
     }
     return $entity;
 }
Пример #4
0
 /**
  * Create contact (if its new)
  * @param  Entity $contact
  * @return Int
  */
 protected function createContact(Entity $contact)
 {
     // If contact already existed, just return id.
     if ($contact->getId()) {
         return $contact->getId();
     }
     return $this->contactRepo->create($contact);
 }
Пример #5
0
 public function update(Entity $entity)
 {
     $record = $this->json_transcoder->encode($entity->getChanged(), $this->json_properties);
     return $this->executeUpdate(['id' => $entity->getId()], $record);
 }