Ejemplo n.º 1
0
 /**
  * test Croogo::hookApiComponent
  */
 public function testHookApiComponent()
 {
     $hooks = Configure::read('Hook.controller_properties');
     Configure::write('Hook.controller_properties', array());
     Croogo::hookApiComponent('Example', 'Example.ExampleApi');
     Croogo::hookApiComponent('Example', array('Users.UserApi' => array('priority' => 2)));
     $expected = array('Example' => array('_apiComponents' => array('Example.ExampleApi' => array('priority' => 8), 'Users.UserApi' => array('priority' => 2))));
     $result = Configure::read('Hook.controller_properties');
     $this->assertEquals($expected, $result);
     Configure::write('Hook.controller_properties', $hooks);
 }
Ejemplo n.º 2
0
 /**
  * Test Setup Component
  */
 public function testSetupComponent()
 {
     $request = new CakeRequest('/api/v1.0/users');
     $request->addParams(array('api' => 'api', 'prefix' => 'v1.0'));
     $controller = new TestAppController($request);
     $defaultComponents = $controller->components;
     $this->assertEmpty($controller->_apiComponents);
     $key = 'Hook.controller_properties.TestApp._apiComponents';
     Configure::write($key, array('BogusApi'));
     Croogo::hookApiComponent('TestApp', 'Example.ImaginaryApi');
     $expected = array('BogusApi' => array('className' => 'BogusApi', 'priority' => 8), 'ImaginaryApi' => array('className' => 'Example.ImaginaryApi', 'priority' => 8));
     $controller = new TestAppController($request);
     $this->assertEquals($expected, $controller->_apiComponents);
     $merged = Hash::merge($defaultComponents, array('BogusApi'), array('Example.ImaginaryApi' => array('priority' => 8)));
     $this->assertEquals($merged, $controller->components);
     Configure::delete('Hook.controller_properties.TestApp');
 }
Ejemplo n.º 3
0
<?php

Croogo::hookApiComponent('Users', 'Users.UserApi');
/**
 * Failed login attempts
 *
 * Default is 5 failed login attempts in every 5 minutes
 */
$cacheConfig = array_merge(Configure::read('Cache.defaultConfig'), array('groups' => array('users')));
$failedLoginDuration = 300;
Configure::write('User.failed_login_limit', 5);
Configure::write('User.failed_login_duration', $failedLoginDuration);
CroogoCache::config('users_login', array_merge($cacheConfig, array('duration' => '+' . $failedLoginDuration . ' seconds', 'groups' => array('users'))));
Croogo::hookAdminRowAction('Users/admin_index', 'Reset Password', array('admin:true/plugin:users/controller:users/action:reset_password/:id' => array('title' => false, 'options' => array('icon' => 'unlock', 'tooltip' => array('data-title' => __d('croogo', 'Reset password'))))));
Ejemplo n.º 4
0
<?php

$cacheConfig = array_merge(Configure::read('Cache.defaultConfig'), array('groups' => array('nodes')));
CroogoCache::config('nodes', $cacheConfig);
CroogoCache::config('nodes_view', $cacheConfig);
CroogoCache::config('nodes_promoted', $cacheConfig);
CroogoCache::config('nodes_term', $cacheConfig);
CroogoCache::config('nodes_index', $cacheConfig);
Croogo::hookApiComponent('Nodes', 'Nodes.NodeApi');
Croogo::hookComponent('*', 'Nodes.Nodes');
Croogo::hookHelper('*', 'Nodes.Nodes');
// Configure Wysiwyg
Croogo::mergeConfig('Wysiwyg.actions', array('Nodes/admin_add' => array(array('elements' => 'NodeBody')), 'Nodes/admin_edit' => array(array('elements' => 'NodeBody')), 'Translate/admin_edit' => array(array('elements' => 'NodeBody'))));
Croogo::mergeConfig('Translate.models.Node', array('fields' => array('title' => 'titleTranslation', 'excerpt' => 'excerptTranslation', 'body' => 'bodyTranslation'), 'translateModel' => 'Nodes.Node'));