当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassRegistry::removeObject方法代码示例

本文整理汇总了PHP中ClassRegistry::removeObject方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassRegistry::removeObject方法的具体用法?PHP ClassRegistry::removeObject怎么用?PHP ClassRegistry::removeObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ClassRegistry的用法示例。


在下文中一共展示了ClassRegistry::removeObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cached

	function cached($url) {
		if (Configure::read('Cache.check') === true) {
			$path = $this->here;
			if ($this->here == '/') {
				$path = 'home';
			}
			if($this->Session->check('Auth.User._id')){
				//$path = $_SESSION['Auth']['User']['_id'].'_'.strtolower(Inflector::slug($path));
				$path = '4d33940fda220a9606000003_'.strtolower(Inflector::slug($path));
			}else{
				$path = strtolower(Inflector::slug($path));
			}

			$filename = CACHE . 'views' . DS . $path . '.php';

			if (!file_exists($filename)) {
				$filename = CACHE . 'views' . DS . $path . '_index.php';
			}

			if (file_exists($filename)) {
				if (!class_exists('View')) {
					App::import('View', 'View', false);
				}
				$controller = null;
				$view =& new View($controller);
				$return = $view->renderCache($filename, getMicrotime());
				if (!$return) {
					ClassRegistry::removeObject('view');
				}
				return $return;
			}
		}
		return false;
	}
开发者ID:ninetwentyfour,项目名称:Homkora,代码行数:34,代码来源:my_dispatcher.php

示例2: admin_index

 /**
  * [ADMIN] サイトマップXML生成実行ページ
  */
 public function admin_index()
 {
     $path = WWW_ROOT . Configure::read('Sitemapxml.filename');
     if ($this->request->data) {
         $sitemap = $this->requestAction('/admin/sitemapxml/sitemapxml/create', array('return', $this->request->data));
         ClassRegistry::removeObject('View');
         $File = new File($path);
         $File->write($sitemap);
         $File->close();
         $this->setMessage('サイトマップの生成が完了しました。');
         chmod($path, 0666);
     }
     $dirWritable = true;
     $fileWritable = true;
     if (file_exists($path)) {
         if (!is_writable($path)) {
             $fileWritable = false;
         }
     } else {
         if (!is_writable(dirname($path))) {
             $dirWritable = false;
         }
     }
     $this->set('path', $path);
     $this->set('fileWritable', $fileWritable);
     $this->set('dirWritable', $dirWritable);
     $this->pageTitle = 'サイトマップXML作成';
     $this->render('index');
 }
开发者ID:kaburk,项目名称:basercms-sitemapxml,代码行数:32,代码来源:SitemapxmlController.php

示例3: startTest

 public function startTest($method)
 {
     parent::startTest($method);
     $this->loadFixtures('Roster', 'Payment', 'PaymentOption', 'Involvement', 'PaymentType', 'Role', 'RolesRoster', 'RosterStatus');
     $CreditCard = new MockRosterCreditCard();
     $CreditCard->setReturnValue('save', true);
     ClassRegistry::removeObject('CreditCard');
     ClassRegistry::addObject('CreditCard', $CreditCard);
     $this->Roster =& ClassRegistry::init('Roster');
 }
开发者ID:styfle,项目名称:core,代码行数:10,代码来源:roster.test.php

示例4: startTest

 /**
  * startTest
  *
  * @return void
  * @access public
  */
 public function startTest()
 {
     ClassRegistry::flush();
     Router::reload();
     $null = null;
     $this->View = new View($null);
     ClassRegistry::removeObject('view');
     ClassRegistry::addObject('view', $this->View);
     $this->TinyMce = new TinyMceHelper();
     $this->TinyMce->Html = new HtmlHelper();
 }
开发者ID:radig,项目名称:TinyMCE,代码行数:17,代码来源:tiny_mce.test.php

示例5: startTest

 public function startTest($method)
 {
     parent::startTest($method);
     $this->loadFixtures('Attachment');
     $this->SysEmail =& ClassRegistry::init('SysEmail');
     $this->Document =& ClassRegistry::init('Document');
     // detach behaviors so they get deleted properly (since the files don't really exist)
     $this->Document->Behaviors->detach('Media.Transfer');
     $this->Document->Behaviors->detach('Media.Polymorphic');
     $this->Document->Behaviors->detach('Media.Coupler');
     ClassRegistry::removeObject('Document');
     ClassRegistry::addObject('Document', $this->Document);
 }
开发者ID:styfle,项目名称:core,代码行数:13,代码来源:sys_email.test.php

示例6: startTest

 /**
  * Start test callback
  * 
  * @return void
  */
 public function startTest($method)
 {
     parent::startTest($method);
     $this->Http = new MockHttpSocket();
     ClassRegistry::removeObject('http_socket');
     if ($this->__useTestSocket) {
         ClassRegistry::addObject('http_socket', $this->Http);
     }
     if ($this->__useTestSocket) {
         Configure::write('Bitly', array('login' => 'testLogin', 'apiKey' => 'testApiKey'));
     }
     $this->Model = ClassRegistry::init('ModelTest');
     $this->BitlyApi = $this->Model->Behaviors->BitlyApi;
 }
开发者ID:CakeDC,项目名称:bitly,代码行数:19,代码来源:BitlyApiBehaviorTest.php

示例7: init

 /**
  * Initialize the fixture.
  *
  * @param object	Cake's DBO driver (e.g: DboMysql).
  * @access public
  *
  */
 function init()
 {
     if (isset($this->import) && (is_string($this->import) || is_array($this->import))) {
         $import = array();
         if (is_string($this->import) || is_array($this->import) && isset($this->import['model'])) {
             $import = array_merge(array('records' => false), is_array($this->import) ? $this->import : array());
             $import['model'] = is_array($this->import) ? $this->import['model'] : $this->import;
         } elseif (isset($this->import['table'])) {
             $import = array_merge(array('connection' => 'default', 'records' => false), $this->import);
         }
         if (isset($import['model']) && (class_exists($import['model']) || App::import('Model', $import['model']))) {
             $connection = isset($import['connection']) ? $import['connection'] : 'default';
             ClassRegistry::config(array('ds' => $connection));
             $model =& ClassRegistry::init($import['model']);
             $db =& ConnectionManager::getDataSource($model->useDbConfig);
             $db->cacheSources = false;
             $this->fields = $model->schema(true);
             $this->fields[$model->primaryKey]['key'] = 'primary';
             ClassRegistry::config(array('ds' => 'test_suite'));
             ClassRegistry::removeObject($model->alias);
         } elseif (isset($import['table'])) {
             $model =& new Model(null, $import['table'], $import['connection']);
             $db =& ConnectionManager::getDataSource($import['connection']);
             $db->cacheSources = false;
             $model->useDbConfig = $import['connection'];
             $model->name = Inflector::camelize(Inflector::singularize($import['table']));
             $model->table = $import['table'];
             $model->tablePrefix = $db->config['prefix'];
             $this->fields = $model->schema(true);
         }
         if (isset($import['records']) && $import['records'] !== false && isset($model) && isset($db)) {
             $this->records = array();
             $query = array('fields' => array_keys($this->fields), 'table' => $db->fullTableName($model->table), 'alias' => $model->alias, 'conditions' => array(), 'order' => null, 'limit' => null, 'group' => null);
             foreach ($query['fields'] as $index => $field) {
                 $query['fields'][$index] = $db->name($query['alias']) . '.' . $db->name($field);
             }
             $records = $db->fetchAll($db->buildStatement($query, $model), false, $model->alias);
             if ($records !== false && !empty($records)) {
                 $this->records = Set::extract($records, '{n}.' . $model->alias);
             }
         }
     }
     if (!isset($this->table)) {
         $this->table = Inflector::underscore(Inflector::pluralize($this->name));
     }
     if (!isset($this->primaryKey) && isset($this->fields['id'])) {
         $this->primaryKey = 'id';
     }
 }
开发者ID:quinns,项目名称:REST-API,代码行数:56,代码来源:cake_test_fixture.php

示例8: dispatch

 public function dispatch($event, $data = array())
 {
     $return = array();
     // Set shell reference
     ClassRegistry::addObject('EventShell', $this->Dispatcher);
     $result = $this->CakeEvents->dispatchEvent($event, am($data, array('Dispatcher' => $this->Dispatcher)));
     ClassRegistry::removeObject('EventShell');
     if ($result) {
         foreach ($result as $eventResult) {
             if ($eventResult['returns']) {
                 $return[$eventResult['name']] = $eventResult['returns'];
             }
         }
     }
     return $return;
 }
开发者ID:ketanshah79,项目名称:eventful-cakephp,代码行数:16,代码来源:event.php

示例9: dispatch

 /**
  * Wrapper method to Events::dispatchEvent
  *
  * @param string $event Name of the event
  * @param array $data Any data to attach
  * 
  * @return mixed FALSE -or- assoc result array
  */
 public function dispatch($event, $data = array())
 {
     $return = array();
     // Set controller reference
     ClassRegistry::addObject('EventController', $this->Controller);
     // Do whatever it does
     $result = $this->CakeEvents->dispatchEvent($event, am($data, array('Controller' => $this->Controller)));
     // Unset controller reference
     ClassRegistry::removeObject('EventController');
     if ($result) {
         foreach ($result as $eventResult) {
             if ($eventResult['returns']) {
                 $return[$eventResult['name']] = $eventResult['returns'];
             }
         }
     }
     return $return;
 }
开发者ID:essential-zz,项目名称:eventful-cakephp,代码行数:26,代码来源:event.php

示例10: startTest

 public function startTest($method)
 {
     parent::startTest($method);
     $this->Payments =& new TestPaymentsController();
     $this->Payments->__construct();
     $this->Payments->constructClasses();
     $this->Payments->Notifier->QueueEmail = new MockPaymentsQueueEmailComponent();
     $this->Payments->Notifier->QueueEmail->enabled = true;
     $this->Payments->Notifier->QueueEmail->initialize($this->Payments);
     $this->Payments->Notifier->QueueEmail->setReturnValue('_smtp', true);
     $this->Payments->Notifier->QueueEmail->setReturnValue('_mail', true);
     $CreditCard = new CreditCard();
     $CreditCard->setGateway(new TestPaymentsControllerAuthorizeDotNetComponent());
     ClassRegistry::removeObject('CreditCard');
     ClassRegistry::addObject('CreditCard', $CreditCard);
     ClassRegistry::init('CreditCard');
     // necessary fixtures
     $this->loadFixtures('Payment', 'User', 'Roster', 'PaymentType', 'PaymentOption', 'Involvement', 'InvolvementType', 'Profile', 'Address', 'Leader');
     $this->testController = $this->Payments;
 }
开发者ID:styfle,项目名称:core,代码行数:20,代码来源:payments_controller.test.php

示例11: _render

 public function _render($content, $title)
 {
     $this->initMessage();
     $viewClass = $this->_controller->view;
     if ($viewClass != 'View') {
         list($plugin, $viewClass) = pluginSplit($viewClass);
         $viewClass = 'View';
         App::import('View', $this->_controller->view);
     }
     $View = new $viewClass($this->Controller);
     $View->layout = $this->layout;
     if ($this->sendAs === 'both') {
         $htmlContent = $content;
         $content = $View->element('email' . DS . 'text' . DS . $this->template, array('content' => $content), true);
         $View->layoutPath = 'email' . DS . 'text';
         $content = explode("\n", $this->textMessage = str_replace(array("\r\n", "\r"), "\n", $View->renderLayout($content)));
         $htmlContent = $View->element('email' . DS . 'html' . DS . $this->template, array('content' => $htmlContent), true);
         $View->layoutPath = 'email' . DS . 'html';
         $htmlContent = explode("\n", $this->htmlMessage = str_replace(array("\r\n", "\r"), "\n", $View->renderLayout($htmlContent)));
         // Set message body (both html and plain text)
         // $this->message->setBody(implode("\n", $htmlContent), 'text/html')
         // ->addPart(implode("\n", $content), 'text/plain');
         ClassRegistry::removeObject('view');
         return $htmlContent;
     }
     //  $content = $View->element('email' . DS . $this->sendAs . DS . $this->template, array('content' => $content), true);
     $View->layoutPath = 'email' . DS . $this->sendAs;
     $content = explode("\n", $rendered = str_replace(array("\r\n", "\r"), "\n", $View->renderLayout($content)));
     if ($this->sendAs === 'html') {
         $this->htmlMessage = $rendered;
     } else {
         $this->textMessage = $rendered;
     }
     // Set message body
     // $this->message->setBody($rendered, $this->getContentType($this->sendAs));
     ClassRegistry::removeObject('view');
     return $content;
 }
开发者ID:jgprolluxer,项目名称:prosales,代码行数:38,代码来源:SwiftMailerComponent.php

示例12: startTest

 public function startTest($method)
 {
     parent::startTest($method);
     $this->loadFixtures('Roster', 'User', 'Involvement', 'Group', 'Date', 'Payment', 'Notification', 'PaymentOption', 'PaymentType', 'InvolvementType', 'Role', 'RolesRoster', 'Leader', 'Ministry');
     $this->Rosters =& new MockRostersController();
     $this->Rosters->__construct();
     $this->Rosters->constructClasses();
     $this->Rosters->Notifier->QueueEmail = new MockRostersQueueEmailComponent();
     $this->Rosters->Notifier->QueueEmail->enabled = true;
     $this->Rosters->Notifier->QueueEmail->initialize($this->Rosters);
     $this->Rosters->Notifier->QueueEmail->setReturnValue('_smtp', true);
     $this->Rosters->Notifier->QueueEmail->setReturnValue('_mail', true);
     $CreditCard =& new MockRostersCreditCard();
     $CreditCard->something = 'nothing';
     $CreditCard->setReturnValue('save', true);
     $CreditCard->setReturnValue('saveAll', true);
     ClassRegistry::removeObject('CreditCard');
     ClassRegistry::addObject('CreditCard', $CreditCard);
     ClassRegistry::init('CreditCard');
     $this->loadSettings();
     $this->Rosters->setReturnValue('isAuthorized', true);
     $this->testController = $this->Rosters;
 }
开发者ID:styfle,项目名称:core,代码行数:23,代码来源:rosters_controller.test.php

示例13: __renderForm

 /**
  * Render the form
  *
  * @param string $formData Data used to build form
  *
  * @return string The rendered form
  * @access private
  */
 function __renderForm($formData)
 {
     $content = '';
     $viewClass = $this->Controller->view;
     if ($viewClass != 'View') {
         if (strpos($viewClass, '.') !== false) {
             list($plugin, $viewClass) = explode('.', $viewClass);
         }
         $viewClass = $viewClass . 'View';
         App::import('View', $this->Controller->view);
     }
     $View = new $viewClass($this->Controller);
     $View->plugin = 'cforms';
     $content = $View->element('form', array('formData' => $formData), true);
     ClassRegistry::removeObject('view');
     return $content;
 }
开发者ID:rchavik,项目名称:croogo-cakeforms,代码行数:25,代码来源:cforms.php

示例14: testScriptStartAndScriptEnd

 /**
  * test script tag output buffering when using scriptStart() and scriptEnd();
  *
  * @return void
  */
 function testScriptStartAndScriptEnd()
 {
     $result = $this->Html->scriptStart(array('safe' => true));
     $this->assertNull($result);
     echo 'this is some javascript';
     $result = $this->Html->scriptEnd();
     $expected = array('script' => array('type' => 'text/javascript'), $this->cDataStart, 'this is some javascript', $this->cDataEnd, '/script');
     $this->assertTags($result, $expected);
     $result = $this->Html->scriptStart(array('safe' => false));
     $this->assertNull($result);
     echo 'this is some javascript';
     $result = $this->Html->scriptEnd();
     $expected = array('script' => array('type' => 'text/javascript'), 'this is some javascript', '/script');
     $this->assertTags($result, $expected);
     ClassRegistry::removeObject('view');
     $View =& new HtmlHelperMockView();
     $View->expectOnce('addScript');
     ClassRegistry::addObject('view', $View);
     $result = $this->Html->scriptStart(array('safe' => false, 'inline' => false));
     $this->assertNull($result);
     echo 'this is some javascript';
     $result = $this->Html->scriptEnd();
     $this->assertNull($result);
 }
开发者ID:asairoha,项目名称:pj01,代码行数:29,代码来源:html.test.php

示例15: generate

 /**
  * Generates a mocked controller and mocks any classes passed to `$mocks`. By
  * default, `_stop()` is stubbed as is sending the response headers, so to not
  * interfere with testing.
  *
  * ### Mocks:
  *
  * - `methods` Methods to mock on the controller. `_stop()` is mocked by default
  * - `models` Models to mock. Models are added to the ClassRegistry so they any
  *   time they are instantiated the mock will be created. Pass as key value pairs
  *   with the value being specific methods on the model to mock. If `true` or
  *   no value is passed, the entire model will be mocked.
  * - `components` Components to mock. Components are only mocked on this controller
  *   and not within each other (i.e., components on components)
  *
  * @param string $controller Controller name
  * @param array $mocks List of classes and methods to mock
  * @return Controller Mocked controller
  * @throws MissingControllerException When controllers could not be created.
  * @throws MissingComponentException When components could not be created.
  */
 public function generate($controller, $mocks = array())
 {
     list($plugin, $controller) = pluginSplit($controller);
     if ($plugin) {
         App::uses($plugin . 'AppController', $plugin . '.Controller');
         $plugin .= '.';
     }
     App::uses($controller . 'Controller', $plugin . 'Controller');
     if (!class_exists($controller . 'Controller')) {
         throw new MissingControllerException(array('class' => $controller . 'Controller', 'plugin' => substr($plugin, 0, -1)));
     }
     ClassRegistry::flush();
     $mocks = array_merge_recursive(array('methods' => array('_stop'), 'models' => array(), 'components' => array()), (array) $mocks);
     list($plugin, $name) = pluginSplit($controller);
     $_controller = $this->getMock($name . 'Controller', $mocks['methods'], array(), '', false);
     $_controller->name = $name;
     $request = $this->getMock('CakeRequest');
     $response = $this->getMock('CakeResponse', array('_sendHeader'));
     $_controller->__construct($request, $response);
     $config = ClassRegistry::config('Model');
     foreach ($mocks['models'] as $model => $methods) {
         if (is_string($methods)) {
             $model = $methods;
             $methods = true;
         }
         if ($methods === true) {
             $methods = array();
         }
         ClassRegistry::init($model);
         list($plugin, $name) = pluginSplit($model);
         $config = array_merge((array) $config, array('name' => $model));
         $_model = $this->getMock($name, $methods, array($config));
         ClassRegistry::removeObject($name);
         ClassRegistry::addObject($name, $_model);
     }
     foreach ($mocks['components'] as $component => $methods) {
         if (is_string($methods)) {
             $component = $methods;
             $methods = true;
         }
         if ($methods === true) {
             $methods = array();
         }
         list($plugin, $name) = pluginSplit($component, true);
         $componentClass = $name . 'Component';
         App::uses($componentClass, $plugin . 'Controller/Component');
         if (!class_exists($componentClass)) {
             throw new MissingComponentException(array('class' => $componentClass));
         }
         $_component = $this->getMock($componentClass, $methods, array(), '', false);
         $_controller->Components->set($name, $_component);
     }
     $_controller->constructClasses();
     $this->__dirtyController = false;
     $this->controller = $_controller;
     return $this->controller;
 }
开发者ID:rufl,项目名称:ATP,代码行数:78,代码来源:ControllerTestCase.php


注:本文中的ClassRegistry::removeObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。