/** * Sets up the configuration for the model, and loads ACL models if they haven't been already * * @param Table $model Table instance being attached * @param array $config Configuration * @return void */ public function __construct(Table $model, array $config = []) { $this->_table = $model; if (isset($config[0])) { $config['type'] = $config[0]; unset($config[0]); } if (isset($config['type'])) { $config['type'] = strtolower($config['type']); } parent::__construct($model, $config); $types = $this->_typeMaps[$this->config()['type']]; if (!is_array($types)) { $types = [$types]; } foreach ($types as $type) { $alias = Inflector::pluralize($type); $className = App::className($alias . 'Table', 'Model/Table'); if ($className == false) { $className = App::className('Acl.' . $alias . 'Table', 'Model/Table'); } $config = []; if (!TableRegistry::exists($alias)) { $config = ['className' => $className]; } $model->hasMany($type, ['targetTable' => TableRegistry::get($alias, $config)]); } if (!method_exists($model->entityClass(), 'parentNode')) { trigger_error(__d('cake_dev', 'Callback {0} not defined in {1}', ['parentNode()', $model->entityClass()]), E_USER_WARNING); } }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Medias') ? [] : ['className' => 'Media\\Model\\Table\\MediasTable']; $this->Medias = TableRegistry::get('Medias', $config); $this->pictures = ['jpg', 'png', 'gif', 'bmp']; }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Bookmarks') ? [] : ['className' => 'App\\Model\\Table\\BookmarksTable']; $this->Bookmarks = TableRegistry::get('Bookmarks', $config); // parent::setUp(); // $this->Bookmarks = TableRegistry::get('Bookmarks'); }
/** * Render a multi select with all available tags of entity and the tags of attachment preselected * * @param EntityInterface $entity the entity to get all allowed tags from * @param Attachment\Model\Entity\Attachment $attachment the attachment entity to add the tag to * @return string */ public function tagsChooser(EntityInterface $entity, $attachment) { if (!TableRegistry::exists($entity->source())) { throw new Cake\Network\Exception\MissingTableException('Could not find Table ' . $entity->source()); } $Table = TableRegistry::get($entity->source()); return $this->Form->select('tags', $Table->getAttachmentsTags(), ['type' => 'select', 'class' => 'tag-chooser', 'style' => 'display: block; width: 100%', 'label' => false, 'multiple' => true, 'value' => $attachment->tags]); }
/** * setUp method * * It will set the needed Tables. */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Todos') ? [] : ['className' => 'App\\Model\\Table\\TodosTable']; $this->Todos = TableRegistry::get('Todos', $config); $config = TableRegistry::exists('Users') ? [] : ['className' => 'App\\Model\\Table\\UsersTable']; $this->Users = TableRegistry::get('Users', $config); }
protected function foreignTable(Token $token) { $options = []; if (!TableRegistry::exists($token['foreign_alias'])) { $options = ['table' => $token['foreign_table']]; } return TableRegistry::get($token['foreign_alias'], $options); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Comments') ? [] : ['className' => 'App\\Model\\Table\\CommentsTable']; $this->Comments = TableRegistry::get('Comments', $config); $this->Comment_Reactions = TableRegistry::get('Comment_Reactions'); $this->Users = TableRegistry::get('Users'); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Times') ? [] : ['className' => 'App\\Model\\Table\\TimesTable']; $this->Times = TableRegistry::get('Times', $config); $this->CrudData = new CrudData($this->Times); $this->columnKeys = array_keys($this->CrudData->columns()); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $this->image = TMP . 'testHelper.png'; $config = TableRegistry::exists('Medias') ? [] : ['className' => 'Media\\Model\\Table\\MediasTable']; $this->Model = TableRegistry::get('Medias', $config); $this->Posts = TableRegistry::get('Posts'); $this->Posts->addAssociations(['hasMany' => ['Media' => ['className' => 'Media.Medias', 'foreignKey' => 'ref_id', 'order' => 'Media.position ASC', 'conditions' => 'ref = "' . $this->Model->alias() . '"', 'dependant' => true]], 'belongsTo' => ['Thumb' => ['className' => 'Media.Medias', 'foreignKey' => 'media_id']]]); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); TableRegistry::clear(); $config = TableRegistry::exists('Notifications.NotificationQueue') ? [] : ['className' => 'Notifications\\Model\\Table\\NotificationQueueTable']; $this->NotificationQueue = TableRegistry::get('Notifications.NotificationQueues', $config); $config = TableRegistry::exists('Notifications.NotificationContents') ? [] : ['className' => 'Notifications\\Model\\Table\\NotificationContentsTable']; $this->NotificationContents = TableRegistry::get('Notifications.NotificationContents', $config); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Trackings') ? [] : ['className' => 'App\\Model\\Table\\TrackingsTable']; $this->Trackings = TableRegistry::get('Trackings', $config); $config = TableRegistry::exists('Todos') ? [] : ['className' => 'App\\Model\\Table\\TodosTable']; $this->Todos = TableRegistry::get('Todos', $config); $this->Trackable = new TrackableBehavior($this->Todos); }
/** * Configure the instance * */ public function __construct() { if (defined('PHPUNIT_TESTSUITE') == 1) { return; } // $this->NotificationQueue = \Cake\Orm\TableRegistry::get('Notifications.NotificationQueue'); $config = TableRegistry::exists('NotificationQueue') ? [] : ['className' => 'Notifications\\Model\\Table\\NotificationQueueTable']; $this->NotificationQueue = TableRegistry::get('NotificationQueue', $config); $this->Users = TableRegistry::get('Users'); }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('UsersTypeMissions') ? [] : ['className' => 'App\\Model\\Table\\UsersTypeMissionsTable']; $this->UsersTypeMissions = TableRegistry::get('UsersTypeMissions', $config); $config = TableRegistry::exists('Users') ? [] : ['className' => 'App\\Model\\Table\\UsersTable']; $this->Users = TableRegistry::get('Users', $config); $config = TableRegistry::exists('Visits') ? [] : ['className' => 'App\\Model\\Table\\VisitsTable']; $this->Visits = TableRegistry::get('Visits', $config); }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Projects') ? [] : ['className' => 'App\\Model\\Table\\ProjectsTable']; $this->Projects = TableRegistry::get('Projects', $config); $config = TableRegistry::exists('Organizations') ? [] : ['className' => 'App\\Model\\Table\\OrganizationsTable']; $this->Organizations = TableRegistry::get('Organizations', $config); $config = TableRegistry::exists('Users') ? [] : ['className' => 'App\\Model\\Table\\UsersTable']; $this->Users = TableRegistry::get('Users', $config); }
/** * Constructor * */ public function __construct() { $config = []; if (!TableRegistry::exists('Permissions')) { $config = ['className' => App::className('Acl.PermissionsTable', 'Model/Table')]; } $this->Permission = TableRegistry::get('Permissions', $config); $this->Aro = $this->Permission->Aros->target(); $this->Aco = $this->Permission->Acos->target(); }
/** * Constructor. Looks at Session configuration information and * sets up the session model. * * @param array $config The configuration for this engine. It requires the 'model' * key to be present corresponding to the Table to use for managing the sessions. */ public function __construct(array $config = []) { if (empty($config['model'])) { $config = TableRegistry::exists('Sessions') ? [] : ['table' => 'sessions']; $this->_table = TableRegistry::get('Sessions', $config); } else { $this->_table = TableRegistry::get($config['model']); } $this->_timeout = ini_get('session.gc_maxlifetime'); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $this->image = TMP . 'testHelper.png'; $this->resizedImage = TMP . 'testHelper_50x50.jpg'; $config = TableRegistry::exists('Medias') ? [] : ['className' => 'Media\\Model\\Table\\MediasTable']; $this->Medias = TableRegistry::get('Medias', $config); $this->Medias = $this->getMockForModel('Media.Medias', array('move_uploaded_file')); $this->Medias->expects($this->any())->method('move_uploaded_file')->will($this->returnCallback([$this, 'testMoveUploadedFile'])); $this->Utility = new Utility(); }
/** * Constructor. Looks at Session configuration information and * sets up the session model. * */ public function __construct() { $modelAlias = Configure::read('Session.handler.model'); if (empty($modelAlias)) { $config = TableRegistry::exists('Sessions') ? [] : ['table' => 'cake_sessions']; $this->_table = TableRegistry::get('Sessions', $config); } else { $this->_table = TableRegistry::get($modelAlias); } $this->_timeout = Configure::read('Session.timeout') * 60; }
/** * Get a model object for a class name. * * @param string $className Name of class you want model to be. * @param string $table Table name * @return \Cake\ORM\Table Table instance */ public function getTableObject($className, $table) { $newTableName = preg_replace('/' . $this->getPrefix() . '/i', '', $table); $newClassName = $this->_camelize($newTableName); if (TableRegistry::exists($newClassName)) { return TableRegistry::get($newClassName); } $finalTableName = $this->getPrefix() . $newTableName; $model = TableRegistry::get($newClassName, ['name' => $newClassName, 'connection' => ConnectionManager::get($this->connection)]); $model->table($finalTableName); return $model; }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $dir = dirname(__DIR__) . DS . '..' . DS . 'data' . DS . 'CsvMigrations' . DS; Configure::write('CsvMigrations.migrations.path', $dir . 'migrations' . DS); Configure::write('CsvMigrations.lists.path', $dir . 'lists' . DS); Configure::write('CsvMigrations.migrations.filename', 'migration'); $mockTrait = $this->getMockForTrait(MigrationTrait::class); $this->csvData = $mockTrait->getFieldsDefinitions($this->tableName); $config = TableRegistry::exists($this->tableName) ? [] : ['className' => 'CsvMigrations\\Test\\TestCase\\Model\\Table\\FooTable']; $this->FooTable = TableRegistry::get($this->tableName, $config); $this->fhf = new FieldHandlerFactory(); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $dir = dirname(__DIR__) . DS . '..' . DS . '..' . DS . 'data' . DS . 'CsvMigrations' . DS; /* point to test data */ Configure::write('CsvMigrations.migrations.path', $dir . 'migrations' . DS); Configure::write('CsvMigrations.lists.path', $dir . 'lists' . DS); Configure::write('CsvMigrations.migrations.filename', 'migration'); $config = TableRegistry::exists('Foo') ? [] : ['className' => 'CsvMigrations\\Test\\TestCase\\Model\\Table\\FooTable']; $this->FooTable = TableRegistry::get('Foo', $config); }
/** * SetUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Missions') ? [] : ['className' => 'App\\Model\\Table\\MissionsTable']; $this->Missions = TableRegistry::get('Missions', $config); $config = TableRegistry::exists('Projects') ? [] : ['className' => 'App\\Model\\Table\\ProjectsTable']; $this->Projects = TableRegistry::get('Projects', $config); $config = TableRegistry::exists('MissionLevels') ? [] : ['className' => 'App\\Model\\Table\\MissionLevelsTable']; $this->Levels = TableRegistry::get('MissionLevels', $config); $config = TableRegistry::exists('TypeMissions') ? [] : ['className' => 'App\\Model\\Table\\TypeMissionsTable']; $this->Type = TableRegistry::get('TypeMissions', $config); $config = TableRegistry::exists('Users') ? [] : ['className' => 'App\\Model\\Table\\UsersTable']; $this->Users = TableRegistry::get('Users', $config); }
/** * [setupAssociations description] * @param [type] $table [description] * @"param ["type] $fields [description] * @return void */ protected function _setupAssociations($table, $fields) { $alias = $this->_table->registryAlias(); foreach ($fields as $field => $type) { $assocType = $type == 'many' ? 'hasMany' : 'hasOne'; $name = $this->_fieldName($field); if (!TableRegistry::exists($name)) { $fieldTable = TableRegistry::get($name, ['className' => $table, 'alias' => $name, 'table' => $this->_imagesTable->table()]); } else { $fieldTable = TableRegistry::get($name); } $this->_table->{$assocType}($name, ['targetTable' => $fieldTable, 'foreignKey' => 'foreign_key', 'joinType' => 'LEFT', 'propertyName' => $this->_fieldName($field, false), 'order' => [$name . '.field_index' => 'ASC'], 'conditions' => [$name . '.model' => $alias, $name . '.field' => $field]]); } $this->_table->hasMany($table, ['foreignKey' => 'foreign_key', 'strategy' => 'subquery', 'propertyName' => '_images', 'dependent' => false, 'conditions' => [$table . '.model' => $alias]]); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Posts') ? [] : ['className' => 'ContentsFile\\Test\\App\\Model\\Table\\PostsTable']; $this->Posts = TableRegistry::get('Posts', $config); //fixtureManagerを呼び出し、fixtureを実行する $this->fixtureManager->fixturize($this); $this->fixtureManager->loadSingle('Posts'); $this->fixtureManager->loadSingle('Attachments'); if (!defined('CONTENTS_FILE_CACHE_PATH')) { define('CONTENTS_FILE_CACHE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/test_app/App/tmp/'); } if (!defined('CONTENTS_FILE_PATH')) { define('CONTENTS_FILE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/test_app/App/files/'); } $this->demoFileDir = dirname(dirname(dirname(dirname(__FILE__)))) . '/test_app/App/demo/'; }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Visitors') ? [] : ['className' => 'Analyzer\\Model\\Table\\VisitorsTable']; $this->Visitors = TableRegistry::get('Visitors', $config); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Parametros') ? [] : ['className' => 'App\\Model\\Table\\ParametrosTable']; $this->Parametros = TableRegistry::get('Parametros', $config); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Formations') ? [] : ['className' => 'ArticlesManager\\Model\\Table\\FormationsTable']; $this->Formations = TableRegistry::get('Formations', $config); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('Controle') ? [] : ['className' => 'App\\Model\\Table\\ControleTable']; $this->Controle = TableRegistry::get('Controle', $config); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('CharactersSkills') ? [] : ['className' => 'App\\Model\\Table\\CharactersSkillsTable']; $this->CharactersSkills = TableRegistry::get('CharactersSkills', $config); }
/** * setUp method * * @return void */ public function setUp() { parent::setUp(); $config = TableRegistry::exists('ClientTypes') ? [] : ['className' => 'App\\Model\\Table\\ClientTypesTable']; $this->ClientTypes = TableRegistry::get('ClientTypes', $config); }