本文整理汇总了PHP中App::objects方法的典型用法代码示例。如果您正苦于以下问题:PHP App::objects方法的具体用法?PHP App::objects怎么用?PHP App::objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::objects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translations
public function translations()
{
$models = array_diff(App::objects('model'), array('AppModel'));
$translations = array();
$out = "<?php ";
foreach ($models as $model) {
$Model = ClassRegistry::init($model);
$translations[Inflector::humanize(Inflector::underscore($Model->name))] = true;
$translations[$Model->brwConfig['names']['singular']] = true;
$translations[$Model->brwConfig['names']['plural']] = true;
$schema = (array) $Model->schema();
foreach ($schema as $key => $value) {
$translations[Inflector::humanize(str_replace('_id', '', $key))] = true;
}
foreach ($Model->brwConfig['custom_actions'] as $action => $config) {
$translations[$config['title']] = true;
if ($config['confirmMessage']) {
$translations[$config['confirmMessage']] = true;
}
}
}
$translations = array_keys($translations);
foreach ($translations as $translation) {
$out .= "__('" . $translation . "');\n";
}
$forTranslate = ROOT . DS . APP_DIR . DS . 'View' . DS . 'Elements' . DS . '4translate.php';
fwrite(fopen($forTranslate, 'w'), $out);
}
示例2: admin_index
public function admin_index()
{
if ($this->request->is('post') && isset($this->request->data)) {
$models = $this->request->data['Audit']['models'];
$models = array_combine(array_values($models), array_values($models));
$this->Setting->write('Audit.models', json_encode($models));
return $this->redirect(array('action' => 'index'));
}
$plugins = App::objects('plugin');
$models = array();
$cakePlugin = new CakePlugin();
foreach ($plugins as $plugin) {
if (!$cakePlugin->loaded($plugin)) {
continue;
}
$pluginModels = App::objects($plugin . '.Model');
foreach ($pluginModels as $pluginModel) {
if (substr($pluginModel, -8) == 'AppModel') {
continue;
}
$model = $plugin . '.' . $pluginModel;
$models[$model] = $model;
}
}
$this->request->data = array('Audit' => array('models' => json_decode(Configure::read('Audit.models'), true)));
$this->set(compact('models'));
}
示例3: setupDatabase
/**
* Run Migrations and add data in table
*
* @return If migrations have succeeded
*/
public function setupDatabase()
{
$plugins = Configure::read('Core.corePlugins');
$migrationsSucceed = true;
foreach ($plugins as $plugin) {
$migrationsSucceed = $this->runMigrations($plugin);
if (!$migrationsSucceed) {
break;
}
}
if ($migrationsSucceed) {
$path = App::pluginPath('Install') . DS . 'Config' . DS . 'Data' . DS;
$dataObjects = App::objects('class', $path);
foreach ($dataObjects as $data) {
include $path . $data . '.php';
$classVars = get_class_vars($data);
$modelAlias = substr($data, 0, -4);
$table = $classVars['table'];
$records = $classVars['records'];
App::uses('Model', 'Model');
$modelObject =& new Model(array('name' => $modelAlias, 'table' => $table, 'ds' => 'default'));
if (is_array($records) && count($records) > 0) {
foreach ($records as $record) {
$modelObject->create($record);
$modelObject->save();
}
$modelObject->getDatasource()->resetSequence($modelObject->useTable, $modelObject->primaryKey);
}
ClassRegistry::removeObject($modelAlias);
}
}
return $migrationsSucceed;
}
示例4: setUp
/**
* Sets the plugins folder for this test
*
* @return void
*/
public function setUp() {
parent::setUp();
App::build(array(
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
), App::RESET);
App::objects('plugins', null, false);
}
示例5: initialize
/**
* Overwrite shell initialize to dynamically load all queue related tasks.
*
* @return void
*/
public function initialize()
{
// Check for tasks inside plugins and application
$paths = App::path('Console/Command/Task');
foreach ($paths as $path) {
$Folder = new Folder($path);
$res = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
foreach ($res as &$r) {
$r = basename($r, 'Task.php');
}
$this->tasks = $res;
}
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$pluginPaths = App::path('Console/Command/Task', $plugin);
foreach ($pluginPaths as $pluginPath) {
$Folder = new Folder($pluginPath);
$res = $Folder->find('Queue.*Task\\.php');
foreach ($res as &$r) {
$r = $plugin . '.' . basename($r, 'Task.php');
}
$this->tasks = array_merge($this->tasks, $res);
}
}
$conf = Configure::read('Queue');
if (!is_array($conf)) {
$conf = [];
}
// Merge with default configuration vars.
Configure::write('Queue', array_merge(['workers' => 3, 'sleepTime' => 10, 'gcprop' => 10, 'defaultWorkerTimeout' => 2 * MINUTE, 'defaultWorkerRetries' => 4, 'workerMaxRuntime' => 0, 'cleanupTimeout' => DAY, 'exitWhenNothingToDo' => false], $conf));
parent::initialize();
}
示例6: _getFiles
public function _getFiles($type)
{
$files = App::objects($type);
# lib
$paths = (array) App::path($type . 's');
$libFiles = App::objects($type, $paths[0] . 'lib' . DS, false);
$plugins = App::objects('plugin');
if (!empty($plugins)) {
foreach ($plugins as $plugin) {
$pluginFiles = App::objects($type, App::pluginPath($plugin) . $type . 's' . DS, false);
if (!empty($pluginFiles)) {
foreach ($pluginFiles as $t) {
$files[] = $t;
//"$plugin.$type";
}
}
}
}
$files = array_merge($files, $libFiles);
$files = array_unique($files);
$appIndex = array_search('App', $files);
if ($appIndex !== false) {
unset($files[$appIndex]);
}
# no test/tmp files etc (helper.test.php or helper.OLD.php)
foreach ($files as $key => $file) {
if (strpos($file, '.') !== false || !preg_match('/^[\\da-zA-Z_]+$/', $file)) {
unset($files[$key]);
}
}
return $files;
}
示例7: get_plugins
/**
* Returns a list of controllers and actions belonging to plugins
*
* @access public
* @return array
*/
public function get_plugins()
{
$pluginDirs = App::objects('plugin', null, false);
$plugins = array();
foreach ($pluginDirs as $pluginDir){
$pluginClasses = App::objects('controller', APP.'Plugin'. DS .$pluginDir. DS .'Controller', false);
App::import('Controller', $pluginDir.'.'.$pluginDir.'App');
$parentActions = get_class_methods($pluginDir.'AppController');
foreach($pluginClasses as $plugin) {
if (strpos($plugin,'App') === false) {
$plugin = str_ireplace('Controller', '', $plugin);
App::import('Controller', $pluginDir.'.'.$plugin);
$actions = get_class_methods($plugin.'Controller');
foreach($actions as $k => $v) {
if ($v{0} == '_') {
unset($actions[$k]);
}
}
$plugins[$pluginDir][$plugin] = array_diff($actions, $parentActions);
}
}
}
return $plugins;
}
示例8: execute
/**
* Execution method always used for tasks
*
* @return void
*/
public function execute()
{
parent::execute();
//引数のセット
if (isset($this->params[self::KEY_APACHE_OWNER])) {
$owner = Hash::get($this->params, self::KEY_APACHE_OWNER);
$writables = array(APP . 'Config', APP . 'tmp', ROOT . DS . 'composer.json', ROOT . DS . 'bower.json');
foreach ($writables as $file) {
$messages = array();
$ret = null;
$cmd = sprintf('`which chown` %s -R %s 2>&1', $owner, $file);
exec($cmd, $messages, $ret);
}
}
if (array_key_exists(self::KEY_RELEASE, $this->params)) {
$path = ROOT . DS . 'app' . DS . 'Plugin' . DS;
$plugins = array_unique(array_merge(App::objects('plugins'), array_map('basename', glob($path . '*', GLOB_ONLYDIR))));
$folder = new Folder();
foreach ($plugins as $plugin) {
$folder->delete($path . $plugin . DS . '.git');
}
$folder->delete(ROOT . DS . '.git');
$folder->delete(ROOT . DS . '.chef');
}
Configure::write('NetCommons.installed', true);
$this->InstallUtil->saveAppConf();
}
示例9: initialize
/**
* Overwrite shell initialize to dynamically load all Queue Related Tasks.
*
* @return void
*/
public function initialize()
{
$this->_loadModels();
$x = App::objects('Queue.Task');
//'Console/Command/Task'
//$x = App::path('Task', 'Queue');
$paths = App::path('Console/Command/Task');
foreach ($paths as $path) {
$Folder = new Folder($path);
$this->tasks = array_merge($this->tasks, $Folder->find('Queue.*\\.php'));
}
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
$pluginPaths = App::path('Console/Command/Task', $plugin);
foreach ($pluginPaths as $pluginPath) {
$Folder = new Folder($pluginPath);
$res = $Folder->find('Queue.*Task\\.php');
foreach ($res as &$r) {
$r = $plugin . '.' . basename($r, 'Task.php');
}
$this->tasks = array_merge($this->tasks, $res);
}
}
//Config can be overwritten via local app config.
Configure::load('Queue.queue');
$conf = (array) Configure::read('Queue');
//merge with default configuration vars.
Configure::write('Queue', array_merge(['maxruntime' => DAY, 'cleanuptimeout' => MONTH], $conf));
}
示例10: modelExists
public function modelExists($model)
{
if ($model == 'BrwUser') {
return true;
}
return in_array($model, App::objects('model'));
}
示例11: _setMenu
/**
* set menu with app objects controllers or with $menuItems = array('Query', 'Register', 'Plan', 'Verify');
*
* @return void
* @access protected
* @throws
*/
protected function _setMenu()
{
if (isset($this->request->params['prefix']) && $this->request->params['prefix'] == 'admin') {
$excludedMenuItems = array('PhkapaApp', 'Phkapa', 'Query', 'Verify', 'Review', 'Register', 'Plan');
$menuItems = App::objects('Phkapa.Controller');
foreach ($excludedMenuItems as $item) {
$item .= 'Controller';
if (array_search($item, $menuItems) !== '') {
unset($menuItems[array_search($item, $menuItems)]);
}
}
foreach ($menuItems as $key => $value) {
$menuItems[$key] = str_replace('Controller', '', $value);
}
sort($menuItems);
} else {
$menuItems = array('Query', 'Register', 'Review', 'Plan', 'Verify');
$user = $this->Auth->user('name');
/* foreach ($menuItems as $key => $value):
if (!$this->checkAccess($value, $user)) {
unset($menuItems[$key]);
}
endforeach; */
}
$this->set(compact('menuItems'));
}
示例12: _setMenu
/**
* set menu with app objects controllers or with $menuItems = array('Query', 'Register', 'Plan', 'Verify');
*
* @return void
* @access protected
* @throws
*/
protected function _setMenu()
{
if (isset($this->request->params['prefix']) && $this->request->params['prefix'] == 'admin') {
$excludedMenuItems = array('PhkapaApp', 'Phkapa', 'Query', 'Verify', 'Review', 'Register', 'Plan');
$menuItems = App::objects('Phkapa.Controller');
foreach ($excludedMenuItems as $item) {
$item .= 'Controller';
if (array_search($item, $menuItems) !== '') {
unset($menuItems[array_search($item, $menuItems)]);
}
}
foreach ($menuItems as $key => $value) {
$menuItems[$key] = str_replace('Controller', '', $value);
}
sort($menuItems);
$this->set('user_at_string', __n('User', 'Users', 1) . ' ' . $this->Session->read('Auth.User.name') . ' @ ' . __('pHKapa Setup'));
} else {
$menuItems = array('Query', 'Register', 'Review', 'Plan', 'Verify');
$user = $this->Auth->user('name');
/* foreach ($menuItems as $key => $value):
if (!$this->checkAccess($value, $user)) {
unset($menuItems[$key]);
}
endforeach; */
$this->set('user_at_string', __n('User', 'Users', 1) . ' ' . $this->Session->read('Auth.User.name') . ' @ ' . __('pHKapa'));
}
$translationDomain = 'phkapa';
$this->set(compact('menuItems', 'translationDomain'));
}
示例13: index
public function index()
{
if (empty($this->data)) {
$modelIgnoreList = Configure::read('ReportManager.modelIgnoreList');
$models = App::objects('Model');
$models = array_combine($models, $models);
if (isset($modelIgnoreList) && is_array($modelIgnoreList)) {
foreach ($modelIgnoreList as $model) {
if (isset($models[$model])) {
}
unset($models[$model]);
}
}
$this->set('files', $this->listReports());
$this->set('models', $models);
} else {
$modelClass = null;
$oneToManyOption = null;
$fileName = $this->data['ReportManager']['saved_report_option'];
if ($fileName != '') {
$params = explode('.', $fileName);
if (count($params) >= 3) {
$modelClass = $params[0];
if (count($params) > 3) {
$oneToManyOption = $params[1];
}
}
} else {
$modelClass = $this->data['ReportManager']['model'];
$oneToManyOption = $this->data['ReportManager']['one_to_many_option'];
}
$this->redirect(array('action' => 'wizard', $modelClass, $oneToManyOption, urlencode($fileName)));
}
}
示例14: import
public function import()
{
if (isset($this->params['name'])) {
$dataObjects = array(Inflector::camelize(Inflector::singularize($this->params['name'])) . 'Data');
} else {
$dataObjects = App::objects('class', $this->directory);
}
$passFields = null;
if (array_key_exists('pass', $this->params)) {
$passFields = array('created', 'updated', 'modified');
}
foreach ($dataObjects as $data) {
App::import('class', $data, false, $this->directory);
extract(get_class_vars($data));
if (empty($records) || !is_array($records)) {
continue;
}
$Model = ClassRegistry::init($name);
$Model->useDbConfig = $this->connection;
if ($passFields) {
foreach ($records as &$record) {
foreach ($passFields as $field) {
unset($record[$field]);
}
}
}
$Model->query("TRUNCATE `{$Model->table}`");
$success = 'Faild';
if ($Model->saveAll($records, array('validate' => false))) {
$success = 'Success';
}
$this->out("Data imported: {$Model->name} [{$success}]");
}
}
示例15: testInstaller
/**
* @test installing plugins
*/
public function testInstaller()
{
$this->__cleanSystem();
$this->assertTrue(App::import('lib', 'Installer.Installer'), 'Could not import the insatller lib');
$this->assertTrue(App::import('Lib', 'Installer.ReleaseVersion'), 'Could not import Versions lib');
$Installer = new InstallerLib();
$Version = new ReleaseVersion(array('connection' => 'test_suite'));
$connectionDetails = $Installer->cleanConnectionDetails(array('connection' => $this->db->config));
$this->assertTrue($Installer->installPlugin($Version, $connectionDetails));
$expected = array('0' => 'acos', '1' => 'aros', '2' => 'aros_acos', '3' => 'schema_migrations', '4' => 'sessions');
$this->assertEqual($expected, $this->db->listSources());
$this->assertTrue($Installer->installPlugin($Version, $connectionDetails, 'Installer'));
$expected = array('0' => 'acos', '1' => 'aros', '2' => 'aros_acos', '3' => 'core_plugins', '4' => 'schema_migrations', '5' => 'sessions');
$this->assertEqual($expected, $this->db->listSources());
$pluginsToInstall = App::objects('plugin');
natsort($pluginsToInstall);
foreach ($pluginsToInstall as $k => $pluginToInstall) {
if (in_array($pluginToInstall, array('Migrations'))) {
continue;
}
$this->assertTrue($Installer->installPlugin($Version, $connectionDetails, $pluginToInstall), sprintf('%s could not be installed', $pluginToInstall));
}
foreach ($pluginsToInstall as $pluginToInstall) {
$this->__checkVersionCount($pluginToInstall);
}
}