/**
  * Constructor
  *
  * @param ComponentCollection $collection The controller for this request.
  * @param string $settings An array of settings. This class does not use any settings.
  */
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $this->_Collection = $collection;
     $controller = $collection->getController();
     $this->controller($controller);
     $this->settings = Hash::merge($this->settings, $settings);
 }
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     //$settings = array_merge($this->settings, (array)$settings);
     $this->FormalWord = ClassRegistry::init('FormalWord');
     $this->Controller = $collection->getController();
     parent::__construct($collection, $settings);
 }
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $configSettings = (array) Configure::read('PaymentNetwork');
     $settings = array_merge($this->settings, $configSettings, (array) $settings);
     $this->Controller = $collection->getController();
     parent::__construct($collection, $settings);
 }
Esempio n. 4
0
 public function setUp()
 {
     parent::setUp();
     $this->Controller = new EnummPostsController();
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
 }
Esempio n. 5
0
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $settings = array_merge($this->settings, (array) $settings);
     $this->Controller = $collection->getController();
     parent::__construct($collection, $settings);
     $this->init();
 }
Esempio n. 6
0
 public function __construct(ComponentCollection $Collection, $settings = array())
 {
     $settings = array_merge($this->settings, (array) $settings, (array) Configure::read('Auth'));
     $this->Controller = $Collection->getController();
     parent::__construct($Collection, $settings);
     # auto-select multi if necessary
     if ($this->settings['multi'] === null) {
         $Model = $this->getModel();
         if (!empty($Model->hasMany)) {
             foreach ($Model->hasMany as $name => $relation) {
                 if ($name != $this->roleModel) {
                     continue;
                 }
                 $this->settings['multi'] = false;
                 return;
             }
         }
         $Model = $this->getModel();
         if (!empty($Model->hasAndBelongsToMany)) {
             foreach ($Model->hasAndBelongsToMany as $name => $relation) {
                 if ($name != $this->roleModel) {
                     continue;
                 }
                 $this->settings['multi'] = true;
                 return;
             }
         }
         //$this->log('AuthExt component not configured properly (auto select multi failed)');
     }
 }
Esempio n. 7
0
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $settings = array_merge($this->settings, (array) $settings);
     $this->Controller = $collection->getController();
     $this->Model = $this->Controller->{$this->Controller->modelClass};
     $this->modelAlias = $this->Model->alias;
     parent::__construct($collection, $settings);
 }
 /**
  * Overrides base class constructor, sets properties and merges supplied user settings.
  */
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $settings = am($this->defaults, $settings);
     $this->_parseSettings($settings);
     $this->controller = $collection->getController();
     $this->request = $this->controller->request;
     $this->_setupControllersPaths();
     parent::__construct($collection, $settings);
 }
 /**
  * Constructor
  *
  * @author	Anthony Putignano <*****@*****.**>
  * @author  Everton Yoshitani <*****@*****.**>
  * @since	0.1
  * @param	ComponentCollection	$collection	The Component collection used on this request.
  * @param	array				$settings	Array of settings to use.
  * @return	void
  */
 public function __construct(ComponentCollection $Collection, $settings = array())
 {
     $this->Controller = $Collection->getController();
     $this->settings = Hash::merge($this->settings, $settings);
     // This needs to be called here instead in the top of this file
     App::uses('OAuth2Component', 'OAuth2.Controller' . DS . 'Component');
     $this->OAuth2Component = new OAuth2Component($Collection, $this->settings);
     $this->OAuth2Component->initialize($this->Controller);
 }
 /**
  * Setup settings
  * 
  * @param ComponentCollection $collection
  * @param array $settings [optional]
  */
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $this->__controller = $collection->getController();
     parent::__construct($collection, $settings);
     //setup settings
     $this->__setupSettings($settings);
     //setup error message
     $this->__errorMsg = __d('cloggy', 'An error has detected');
 }
Esempio n. 11
0
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $this->Controller = $collection->getController();
     $defaults = array('redirect' => array('add' => array(array($this, 'redirect'), array(array('action' => 'index'))), 'edit' => array(array($this, 'redirect'), array(array('action' => 'index'))), 'delete' => array(array($this, 'redirect'), array(array('action' => 'index')))));
     $settings = Hash::merge($defaults, $settings);
     // configure.
     $this->_set($settings);
     parent::__construct($collection, $settings);
 }
Esempio n. 12
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('Acl.classname', 'HabtmDbAcl');
     Configure::write('Acl.database', 'test');
     $Collection = new ComponentCollection();
     $this->Acl = $Collection->load('Acl', array('habtm' => array('userModel' => 'Employee', 'groupAlias' => 'Department')));
     $this->_setPermissions();
 }
 public function setUp()
 {
     $this->Controller = $this->getMock('AccessLimitTestController', array('dispatchMethod'), array($this->getMock('CakeRequest', array('is'), array(null, false)), $this->getMock('CakeResponse')));
     $this->Model = $this->getMockForModel('Security.AccessLimit');
     ClassRegistry::addObject('AccessLimit', $this->Model);
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Controller->Components->init($this->Controller);
     $this->AccessLimit = $this->Controller->AccessLimit;
 }
 /**
  * Constructor
  *
  * @param ComponentCollection $collection
  * @param array $settings
  * @return void
  */
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $settings = array_merge($this->settings, (array) $settings);
     $this->Controller = $collection->getController();
     if (isset($settings['helper']) and $settings['helper'] !== false) {
         $this->Controller->helpers['Search'] = array('prefix' => $this->_prefix);
     }
     // <-- Cargar helper Search
     $this->setRequest($this->configs);
     parent::__construct($collection, $settings);
 }
Esempio n. 15
0
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $settings = array_merge($this->settings, (array) $settings);
     $this->Controller = $collection->getController();
     $this->CleanTweet = ClassRegistry::init('CleanTweet');
     $this->CleanRepository = ClassRegistry::init('CleanRepository');
     $this->dir = new Folder(WWW_ROOT . 'files', true, 0755);
     $this->filetraining = new File(WWW_ROOT . 'files/jan.train', true, 0644);
     $this->filetesting = new File(WWW_ROOT . 'files/jan.test', true, 0644);
     parent::__construct($collection, $settings);
 }
 public function setUp()
 {
     parent::setUp();
     $request = new CakeRequest(null, false);
     $request->params['ext'] = 'json';
     $this->Controller = new TestRestController($request, $this->getMock('CakeResponse'));
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Rest = new MockRestComponent($collection, $this->settings);
     $this->Rest->request = $request;
     $this->Rest->response = $this->getMock('CakeResponse');
     $this->Controller->Components->init($this->Controller);
 }
Esempio n. 17
0
 /**
  * Generates the component for test
  * Options:
  * - mocks: specify mock methods for each objects
  * - componentOptopns: could be used for component options.
  *
  * @param $options
  * @return void
  */
 public function generateComponent($options = [])
 {
     $options = Hash::merge(['mocks' => ['controller' => ['_stop', 'redirect']], 'componentOptions' => ['setDebuggerTypeAs' => false, 'setExceptionHandler' => false, 'setAuthenticate' => false], 'initialize' => true], $options);
     extract($options);
     $this->request = $this->getMockBuilder('CakeRequest')->setConstructorArgs(['/', false])->setMethods(Hash::get($mocks, 'request'))->getMock();
     $this->response = $this->getMockBuilder('CakeResponse')->setMethods(Hash::get($mocks, 'response'))->getMock();
     $this->controller = $this->getMockBuilder('Controller')->setConstructorArgs([$this->request, $this->response])->setMethods(Hash::get($mocks, 'controller'))->getMock();
     $this->collection = $this->getMockBuilder('ComponentCollection')->setMethods(Hash::get($mocks, 'collection'))->getMock();
     $this->collection->init($this->controller);
     $this->Api = $this->getMockBuilder('ApiComponent')->setConstructorArgs([$this->collection, $componentOptions])->setMethods(Hash::get($mocks, 'Api'))->getMock();
     if ($initialize) {
         $this->Api->initialize($this->controller);
     }
     return $this->Api;
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     // Ensure all requests start with a valid token attached.
     $token = 'cc0a91cfa4f3b703531c1dc4f5f64b89';
     $request = $this->getMock('CakeRequest', array('header'), array(null, false));
     $request->staticExpects($this->any())->method('header')->with('Authorization')->will($this->returnValue('Bearer ' . $token));
     $this->Controller = new StatelessAuthController($request, $this->getMock('CakeResponse'));
     $this->Controller->request = $request;
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Component = new TestStatelessAuthComponent($collection);
     $this->Component->request = $request;
     $this->Component->response = $this->getMock('CakeResponse');
     $this->Controller->Components->init($this->Controller);
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $request = new CakeRequest(null, false);
     $this->Controller = new UploaderTestController($request, $this->getMock('CakeResponse'));
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Uploader = new TestUploaderComponent($collection);
     $this->Controller->Components->init($this->Controller);
     $this->Controller->startupProcess();
     $this->upload1 = array('name' => 'Upload.jpg', 'type' => 'image/jpg', 'tmp_name' => $this->tmpDir . 'upload.jpg', 'error' => (int) 0, 'size' => filesize($this->tmpDir . 'upload.jpg'));
     $this->upload2 = array('name' => 'Upload File 2.txt', 'type' => 'text/plain', 'tmp_name' => $this->tmpDir . 'upload2.txt', 'error' => (int) 0, 'size' => filesize($this->tmpDir . 'upload2.txt'));
     $this->MediaUpload = ClassRegistry::init('MediaUpload');
     $this->Controller->Uploader->setModel($this->MediaUpload);
     $this->uploadResult = null;
 }
 public function setUp()
 {
     parent::setUp();
     // コンポーネントと偽のテストコントローラをセットアップする
     $request = new CakeRequest();
     $response = $this->getMock('CakeResponse');
     $this->Controller = new BcReplacePrefixTestController($request, $response);
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->BcReplacePrefix = new BcReplacePrefixComponent($collection);
     $this->BcReplacePrefix->request = $request;
     $this->BcReplacePrefix->response = $response;
     $this->Controller->Components->init($this->Controller);
     Router::reload();
     Router::connect('/:controller/:action/*');
 }
 public function setUp()
 {
     @session_start();
     parent::setUp();
     // コンポーネントと偽のコントローラをセットアップする
     $request = new CakeRequest();
     $response = $this->getMock('CakeResponse');
     $this->Controller = new BcAuthConfigureTestController($request, $response);
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->BcAuthConfigure = new BcAuthConfigureComponent($collection);
     $this->BcAuthConfigure->request = $request;
     $this->BcAuthConfigure->response = $response;
     $this->Controller->Components->init($this->Controller);
     Router::reload();
     Router::connect('/:controller/:action/*');
 }
Esempio n. 22
0
/**
 * Magic method for lazy loading $components.
 *
 * @param string $name Name of component to get.
 * @return mixed A Component object or null.
 */
	public function __get($name) {
		if (isset($this->_componentMap[$name]) && !isset($this->{$name})) {
			$settings = array_merge((array)$this->_componentMap[$name]['settings'], array('enabled' => false));
			$this->{$name} = $this->_Collection->load($this->_componentMap[$name]['class'], $settings);
		}
		if (isset($this->{$name})) {
			return $this->{$name};
		}
	}
Esempio n. 23
0
/**
 * Initializes all the Components for a controller.
 * Attaches a reference of each component to the Controller.
 *
 * @param Controller $Controller Controller to initialize components for.
 * @return void
 */
	public function init(Controller $Controller) {
		if (empty($Controller->components)) {
			return;
		}
		$this->_Controller = $Controller;
		$components = ComponentCollection::normalizeObjectArray($Controller->components);
		foreach ($components as $name => $properties) {
			$Controller->{$name} = $this->load($properties['class'], $properties['settings']);
		}
	}
 /**
  * Constructor
  *
  * @param object Controller object
  */
 public function __construct(ComponentCollection $collection, $settings)
 {
     $this->controller = $collection->getController();
     $this->_defaults = Set::merge($this->_defaults, $settings);
     # fix for not throwing warning
     if (!isset($this->controller->presetVars)) {
         $this->controller->presetVars = array();
     }
     $model = $this->controller->modelClass;
     if (!empty($settings['model'])) {
         $model = $settings['model'];
     }
     if ($this->controller->presetVars === true) {
         // auto-set the presetVars based on search defitions in model
         $this->controller->presetVars = array();
         $filterArgs = $this->controller->{$model}->filterArgs;
         foreach ($filterArgs as $key => $arg) {
             if ($var = $this->_parseFromModel($arg, $key)) {
                 $this->controller->presetVars[] = $var;
             }
         }
     }
     foreach ($this->controller->presetVars as $key => $field) {
         if ($field === true) {
             if (isset($this->controller->{$model}->filterArgs[$key])) {
                 $field = $this->_parseFromModel($this->controller->{$model}->filterArgs[$key], $key);
             } else {
                 $field = array('type' => 'value');
             }
         }
         if (!isset($field['field'])) {
             $field['field'] = $key;
         }
         $this->controller->presetVars[$key] = $field;
     }
 }
Esempio n. 25
0
 /**
  * Handles automatic pagination of model records.
  *
  * @param Model|string $object Model to paginate (e.g: model instance, or 'Model', or 'Model.InnerModel')
  * @param string|array $scope Conditions to use while paginating
  * @param array $whitelist List of allowed options for paging
  * @return array Model query results
  * @link http://book.cakephp.org/2.0/en/controllers.html#Controller::paginate
  */
 public function paginate($object = null, $scope = array(), $whitelist = array())
 {
     return $this->Components->load('Paginator', $this->paginate)->paginate($object, $scope, $whitelist);
 }
Esempio n. 26
0
/**
 * Constructor
 *
 * @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components
 * @param array $settings Array of configuration settings.
 */
	public function __construct(ComponentCollection $collection, $settings = array()) {
		$this->_controller = $collection->getController();
		parent::__construct($collection, $settings);
	}
Esempio n. 27
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
     Configure::write('Security.cipherSeed', 770011223369876);
     $request = new CakeRequest(null, false);
     $this->Controller = new AuthTestController($request, $this->getMock('CakeResponse'));
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Auth = new TestAuthComponent($collection);
     $this->Auth->request = $request;
     $this->Auth->response = $this->getMock('CakeResponse');
     $this->Controller->Components->init($this->Controller);
     $this->initialized = true;
     Router::reload();
     Router::connect('/:controller/:action/*');
     $User = ClassRegistry::init('AuthUser');
     $User->updateAll(array('password' => $User->getDataSource()->value(Security::hash('cake', null, true))));
 }
 public function __construct(ComponentCollection $collection, $settings)
 {
     $this->controller = $collection->getController();
     $this->model = $this->controller->modelClass;
 }
 /**
  * Constructor
  *
  * If debug is off the component will be disabled and not do any further time tracking
  * or load the toolbar helper.
  *
  * @param ComponentCollection $collection
  * @param array $settings
  * @return \ToolbarComponent
  */
 public function __construct(ComponentCollection $collection, $settings = array())
 {
     $settings = array_merge((array) Configure::read('DebugKit'), $settings);
     $panels = $this->_defaultPanels;
     if (isset($settings['panels'])) {
         $panels = $this->_makePanelList($settings['panels']);
         unset($settings['panels']);
     }
     $this->controller = $collection->getController();
     parent::__construct($collection, array_merge($this->settings, (array) $settings));
     if (!Configure::read('debug') && empty($this->settings['forceEnable'])) {
         $this->enabled = false;
         return false;
     }
     if ($this->settings['autoRun'] === false && !isset($this->controller->request->query['debug'])) {
         $this->enabled = false;
         return false;
     }
     $this->controller->getEventManager()->attach($this);
     DebugMemory::record(__d('debug_kit', 'Component initialization'));
     $this->cacheKey .= $this->Session->read('Config.userAgent');
     if (in_array('DebugKit.History', $panels) || isset($settings['history']) && $settings['history'] !== false) {
         $this->_createCacheConfig();
     }
     $this->_loadPanels($panels, $settings);
     return false;
 }
 /**
  * Test that the constructor sets the settings.
  *
  * @return void
  */
 public function testConstructorSettings()
 {
     $settings = array('ajaxLayout' => 'test_ajax', 'viewClassMap' => array('json' => 'MyPlugin.MyJson'));
     $Collection = new ComponentCollection();
     $Collection->init($this->Controller);
     $RequestHandler = new RequestHandlerComponent($Collection, $settings);
     $this->assertEquals('test_ajax', $RequestHandler->ajaxLayout);
     $this->assertEquals(array('json' => 'MyPlugin.MyJson'), $RequestHandler->settings['viewClassMap']);
 }