Exemple #1
0
 function _addOrEditRole($action)
 {
     $this->role->setAttributes(Ak::pick('name,description,is_enabled', $this->params['role']));
     if ($this->role->save()){
         $this->flash_options = array('seconds_to_close' => 10);
         $this->flash['notice'] = $this->t('Role was successfully '.($action=='add'?'created':'updated'.'.'));
         $this->redirectToAction('listing');
     }
 }
Exemple #2
0
 public function test_should_find_using_named_bindings()
 {
     $this->installAndIncludeModels(array('Hybrid' => 'id,customer_id,input,parent_id'));
     $Hybrid = new Hybrid();
     $customer_id = 12;
     $input = 'abc';
     $parent_id = 123;
     $Hybrid->create(array('customer_id' => $customer_id, 'input' => $input, 'parent_id' => $parent_id));
     $results = $Hybrid->find('all', array('conditions' => array('customer_id = :customer_id AND input = :input AND parent_id = :parent_id', ':customer_id' => $customer_id, ':input' => $input, ':parent_id' => $parent_id)));
     $this->assertEqual(Ak::pick('customer_id,input,parent_id', $results[0]->getAttributes()), array('customer_id' => $customer_id, 'input' => $input, 'parent_id' => $parent_id));
 }
Exemple #3
0
 public function test_should_set_and_get_attributes()
 {
     $this->WebPage->title = 'Akelos.org';
     $this->WebPage->body = 'Akelos PHP framework...';
     $this->WebPage->keywords = array('one', 'two');
     $this->assertNull($this->WebPage->getId());
     $this->assertTrue($this->WebPage->isNewRecord());
     $this->WebPage->save();
     $this->assertFalse($this->WebPage->isNewRecord());
     $this->assertEqual($this->WebPage->title, 'Akelos.org');
     $this->assertEqual(Ak::pick('body', $this->WebPage->getAttributes()), array('body' => 'Akelos PHP framework...'));
     $this->assertEqual($this->WebPage->getAttribute('body'), 'Akelos PHP framework...');
     $this->assertNotNull($this->WebPage->getId());
 }
Exemple #4
0
 private function mapHasManyAssociations($Resource, $associations, $options)
 {
     if (is_array($associations)) {
         foreach ($associations as $k => $v) {
             if (is_int($k)) {
                 $this->mapHasManyAssociations($Resource, $v, $options);
             } else {
                 $this->mapHasManyAssociations($Resource, $k, array_merge($options, array('has_many' => $v)));
             }
         }
     } else {
         $options = array_merge(array('path_prefix' => $Resource->getNestingPathPrefix(), 'name_prefix' => $Resource->getNestingNamePrefix(), 'has_many' => isset($options['has_many']) ? $options['has_many'] : null), Ak::pick($this->_inheritable_options, $options));
         $this->resources($associations, $options);
     }
 }
 public function test_should_pick_parameters()
 {
     $params = array('id' => 3, 'is_enabled' => 1, 'name' => 'Alicia');
     $this->assertEqual(Ak::pick('id,name', $params), array('id' => 3, 'name' => 'Alicia'));
 }