Browse Source

Remove deprecated method calls

chinpei215 8 years ago
parent
commit
a38cb750cf

+ 7 - 7
src/Database/Schema/MysqlSchema.php

@@ -207,9 +207,9 @@ class MysqlSchema extends BaseSchema
             $type === Table::INDEX_FULLTEXT
         );
         if ($isIndex) {
-            $existing = $schema->index($name);
+            $existing = $schema->getIndex($name);
         } else {
-            $existing = $schema->constraint($name);
+            $existing = $schema->getConstraint($name);
         }
 
         // MySQL multi column indexes come back as multiple rows.
@@ -299,7 +299,7 @@ class MysqlSchema extends BaseSchema
      */
     public function columnSql(TableSchema $schema, $name)
     {
-        $data = $schema->column($name);
+        $data = $schema->getColumn($name);
         $out = $this->_driver->quoteIdentifier($name);
         $nativeJson = $this->_driver->supportsNativeJson();
 
@@ -441,7 +441,7 @@ class MysqlSchema extends BaseSchema
      */
     public function constraintSql(TableSchema $schema, $name)
     {
-        $data = $schema->constraint($name);
+        $data = $schema->getConstraint($name);
         if ($data['type'] === Table::CONSTRAINT_PRIMARY) {
             $columns = array_map(
                 [$this->_driver, 'quoteIdentifier'],
@@ -472,7 +472,7 @@ class MysqlSchema extends BaseSchema
         $sql = [];
 
         foreach ($schema->constraints() as $name) {
-            $constraint = $schema->constraint($name);
+            $constraint = $schema->getConstraint($name);
             if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
                 $tableName = $this->_driver->quoteIdentifier($schema->name());
                 $sql[] = sprintf($sqlPattern, $tableName, $this->constraintSql($schema, $name));
@@ -491,7 +491,7 @@ class MysqlSchema extends BaseSchema
         $sql = [];
 
         foreach ($schema->constraints() as $name) {
-            $constraint = $schema->constraint($name);
+            $constraint = $schema->getConstraint($name);
             if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
                 $tableName = $this->_driver->quoteIdentifier($schema->name());
                 $constraintName = $this->_driver->quoteIdentifier($name);
@@ -507,7 +507,7 @@ class MysqlSchema extends BaseSchema
      */
     public function indexSql(TableSchema $schema, $name)
     {
-        $data = $schema->index($name);
+        $data = $schema->getIndex($name);
         $out = '';
         if ($data['type'] === Table::INDEX_INDEX) {
             $out = 'KEY ';

+ 8 - 8
src/Database/Schema/PostgresSchema.php

@@ -250,7 +250,7 @@ class PostgresSchema extends BaseSchema
 
             return;
         }
-        $index = $schema->index($name);
+        $index = $schema->getIndex($name);
         if (!$index) {
             $index = [
                 'type' => $type,
@@ -272,7 +272,7 @@ class PostgresSchema extends BaseSchema
      */
     protected function _convertConstraint($schema, $name, $type, $row)
     {
-        $constraint = $schema->constraint($name);
+        $constraint = $schema->getConstraint($name);
         if (!$constraint) {
             $constraint = [
                 'type' => $type,
@@ -349,7 +349,7 @@ class PostgresSchema extends BaseSchema
      */
     public function columnSql(TableSchema $schema, $name)
     {
-        $data = $schema->column($name);
+        $data = $schema->getColumn($name);
         $out = $this->_driver->quoteIdentifier($name);
         $typeMap = [
             TableSchema::TYPE_TINYINTEGER => ' SMALLINT',
@@ -443,7 +443,7 @@ class PostgresSchema extends BaseSchema
         $sql = [];
 
         foreach ($schema->constraints() as $name) {
-            $constraint = $schema->constraint($name);
+            $constraint = $schema->getConstraint($name);
             if ($constraint['type'] === TableSchema::CONSTRAINT_FOREIGN) {
                 $tableName = $this->_driver->quoteIdentifier($schema->name());
                 $sql[] = sprintf($sqlPattern, $tableName, $this->constraintSql($schema, $name));
@@ -462,7 +462,7 @@ class PostgresSchema extends BaseSchema
         $sql = [];
 
         foreach ($schema->constraints() as $name) {
-            $constraint = $schema->constraint($name);
+            $constraint = $schema->getConstraint($name);
             if ($constraint['type'] === TableSchema::CONSTRAINT_FOREIGN) {
                 $tableName = $this->_driver->quoteIdentifier($schema->name());
                 $constraintName = $this->_driver->quoteIdentifier($name);
@@ -478,7 +478,7 @@ class PostgresSchema extends BaseSchema
      */
     public function indexSql(TableSchema $schema, $name)
     {
-        $data = $schema->index($name);
+        $data = $schema->getIndex($name);
         $columns = array_map(
             [$this->_driver, 'quoteIdentifier'],
             $data['columns']
@@ -497,7 +497,7 @@ class PostgresSchema extends BaseSchema
      */
     public function constraintSql(TableSchema $schema, $name)
     {
-        $data = $schema->constraint($name);
+        $data = $schema->getConstraint($name);
         $out = 'CONSTRAINT ' . $this->_driver->quoteIdentifier($name);
         if ($data['type'] === TableSchema::CONSTRAINT_PRIMARY) {
             $out = 'PRIMARY KEY';
@@ -551,7 +551,7 @@ class PostgresSchema extends BaseSchema
             $out[] = $index;
         }
         foreach ($schema->columns() as $column) {
-            $columnData = $schema->column($column);
+            $columnData = $schema->getColumn($column);
             if (isset($columnData['comment'])) {
                 $out[] = sprintf(
                     'COMMENT ON COLUMN %s.%s IS %s',

+ 7 - 7
src/Database/Schema/SqliteSchema.php

@@ -144,7 +144,7 @@ class SqliteSchema extends BaseSchema
             'null' => !$row['notnull'],
             'default' => $this->_defaultValue($row['dflt_value']),
         ];
-        $primary = $schema->constraint('primary');
+        $primary = $schema->getConstraint('primary');
 
         if ($row['pk'] && empty($primary)) {
             $field['null'] = false;
@@ -154,12 +154,12 @@ class SqliteSchema extends BaseSchema
         // SQLite does not support autoincrement on composite keys.
         if ($row['pk'] && !empty($primary)) {
             $existingColumn = $primary['columns'][0];
-            $schema->addColumn($existingColumn, ['autoIncrement' => null] + $schema->column($existingColumn));
+            $schema->addColumn($existingColumn, ['autoIncrement' => null] + $schema->getColumn($existingColumn));
         }
 
         $schema->addColumn($row['name'], $field);
         if ($row['pk']) {
-            $constraint = (array)$schema->constraint('primary') + [
+            $constraint = (array)$schema->getConstraint('primary') + [
                 'type' => TableSchema::CONSTRAINT_PRIMARY,
                 'columns' => []
             ];
@@ -282,7 +282,7 @@ class SqliteSchema extends BaseSchema
      */
     public function columnSql(TableSchema $schema, $name)
     {
-        $data = $schema->column($name);
+        $data = $schema->getColumn($name);
         $typeMap = [
             TableSchema::TYPE_UUID => ' CHAR(36)',
             TableSchema::TYPE_TINYINTEGER => ' TINYINT',
@@ -381,10 +381,10 @@ class SqliteSchema extends BaseSchema
      */
     public function constraintSql(TableSchema $schema, $name)
     {
-        $data = $schema->constraint($name);
+        $data = $schema->getConstraint($name);
         if ($data['type'] === TableSchema::CONSTRAINT_PRIMARY &&
             count($data['columns']) === 1 &&
-            $schema->column($data['columns'][0])['type'] === TableSchema::TYPE_INTEGER
+            $schema->getColumn($data['columns'][0])['type'] === TableSchema::TYPE_INTEGER
         ) {
             return '';
         }
@@ -448,7 +448,7 @@ class SqliteSchema extends BaseSchema
      */
     public function indexSql(TableSchema $schema, $name)
     {
-        $data = $schema->index($name);
+        $data = $schema->getIndex($name);
         $columns = array_map(
             [$this->_driver, 'quoteIdentifier'],
             $data['columns']

+ 8 - 8
src/Database/Schema/SqlserverSchema.php

@@ -232,9 +232,9 @@ class SqlserverSchema extends BaseSchema
         }
 
         if ($type === Table::INDEX_INDEX) {
-            $existing = $schema->index($name);
+            $existing = $schema->getIndex($name);
         } else {
-            $existing = $schema->constraint($name);
+            $existing = $schema->getConstraint($name);
         }
 
         $columns = [$row['column_name']];
@@ -328,7 +328,7 @@ class SqlserverSchema extends BaseSchema
      */
     public function columnSql(TableSchema $schema, $name)
     {
-        $data = $schema->column($name);
+        $data = $schema->getColumn($name);
         $out = $this->_driver->quoteIdentifier($name);
         $typeMap = [
             TableSchema::TYPE_TINYINTEGER => ' TINYINT',
@@ -430,7 +430,7 @@ class SqlserverSchema extends BaseSchema
         $sql = [];
 
         foreach ($schema->constraints() as $name) {
-            $constraint = $schema->constraint($name);
+            $constraint = $schema->getConstraint($name);
             if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
                 $tableName = $this->_driver->quoteIdentifier($schema->name());
                 $sql[] = sprintf($sqlPattern, $tableName, $this->constraintSql($schema, $name));
@@ -449,7 +449,7 @@ class SqlserverSchema extends BaseSchema
         $sql = [];
 
         foreach ($schema->constraints() as $name) {
-            $constraint = $schema->constraint($name);
+            $constraint = $schema->getConstraint($name);
             if ($constraint['type'] === Table::CONSTRAINT_FOREIGN) {
                 $tableName = $this->_driver->quoteIdentifier($schema->name());
                 $constraintName = $this->_driver->quoteIdentifier($name);
@@ -465,7 +465,7 @@ class SqlserverSchema extends BaseSchema
      */
     public function indexSql(TableSchema $schema, $name)
     {
-        $data = $schema->index($name);
+        $data = $schema->getIndex($name);
         $columns = array_map(
             [$this->_driver, 'quoteIdentifier'],
             $data['columns']
@@ -484,7 +484,7 @@ class SqlserverSchema extends BaseSchema
      */
     public function constraintSql(TableSchema $schema, $name)
     {
-        $data = $schema->constraint($name);
+        $data = $schema->getConstraint($name);
         $out = 'CONSTRAINT ' . $this->_driver->quoteIdentifier($name);
         if ($data['type'] === Table::CONSTRAINT_PRIMARY) {
             $out = 'PRIMARY KEY';
@@ -553,7 +553,7 @@ class SqlserverSchema extends BaseSchema
         // Restart identity sequences
         $pk = $schema->primaryKey();
         if (count($pk) === 1) {
-            $column = $schema->column($pk[0]);
+            $column = $schema->getColumn($pk[0]);
             if (in_array($column['type'], ['integer', 'biginteger'])) {
                 $queries[] = sprintf(
                     "DBCC CHECKIDENT('%s', RESEED, 0)",

+ 1 - 1
src/Database/Schema/TableSchema.php

@@ -430,7 +430,7 @@ class TableSchema implements TableSchemaInterface, SqlGeneratorInterface
             return $this->_columns[$column]['baseType'];
         }
 
-        $type = $this->columnType($column);
+        $type = $this->getColumnType($column);
 
         if ($type === null) {
             return null;

+ 4 - 1
src/Datasource/EntityInterface.php

@@ -33,7 +33,7 @@ use JsonSerializable;
  * @method array getError($field)
  * @method array setErrors(array $fields, $overwrite = false)
  * @method array setError($field, $errors, $overwrite = false)
- * @method $this setAccess(array $properties, $merge = false)
+ * @method $this setAccess($properties, $merge)
  * @method bool isAccessible($property)
  * @method $this setSource($source)
  * @method array getSource()
@@ -138,6 +138,7 @@ interface EntityInterface extends ArrayAccess, JsonSerializable
      * When called with no arguments it will return whether or not there are any
      * dirty property in the entity
      *
+     * @deprecated 3.4.0 Use setDirty() and isDirty() instead.
      * @param string|null $property the field to set or check status for
      * @param null|bool $isDirty true means the property was changed, false means
      * it was not changed and null will make the function return current state
@@ -179,6 +180,7 @@ interface EntityInterface extends ArrayAccess, JsonSerializable
      * When used as a setter, this method will return this entity instance for method
      * chaining.
      *
+     * @deprecated 3.4.0 Use setErrors() and getErrors() instead.
      * @param string|array|null $field The field to get errors for.
      * @param string|array|null $errors The errors to be set for $field
      * @param bool $overwrite Whether or not to overwrite pre-existing errors for $field
@@ -193,6 +195,7 @@ interface EntityInterface extends ArrayAccess, JsonSerializable
      * `$entity->accessible('*', true)` means that any property not specified already
      * will be accessible by default.
      *
+     * @deprecated 3.4.0 Use setAccess() and isAccessible() instead.
      * @param string|array $property Either a single or list of properties to change its accessibility.
      * @param bool|null $set true marks the property as accessible, false will
      * mark it as protected.

+ 5 - 5
src/ORM/Marshaller.php

@@ -70,7 +70,7 @@ class Marshaller
 
         // Is a concrete column?
         foreach (array_keys($data) as $prop) {
-            $columnType = $schema->columnType($prop);
+            $columnType = $schema->getColumnType($prop);
             if ($columnType) {
                 $map[$prop] = function ($value, $entity) use ($columnType) {
                     return Type::build($columnType)->marshal($value);
@@ -216,7 +216,7 @@ class Marshaller
         // dirty so we don't persist empty records.
         foreach ($properties as $field => $value) {
             if ($value instanceof EntityInterface) {
-                $entity->dirty($field, $value->dirty());
+                $entity->setDirty($field, $value->isDirty());
             }
         }
 
@@ -547,7 +547,7 @@ class Marshaller
 
         if (isset($options['accessibleFields'])) {
             foreach ((array)$options['accessibleFields'] as $key => $value) {
-                $entity->accessible($key, $value);
+                $entity->setAccess($key, $value);
             }
         }
 
@@ -581,7 +581,7 @@ class Marshaller
             $properties[$key] = $value;
         }
 
-        $entity->errors($errors);
+        $entity->setErrors($errors);
         if (!isset($options['fields'])) {
             $entity->set($properties);
 
@@ -785,7 +785,7 @@ class Marshaller
         $extra = [];
         foreach ($original as $entity) {
             // Mark joinData as accessible so we can marshal it properly.
-            $entity->accessible('_joinData', true);
+            $entity->setAccess('_joinData', true);
 
             $joinData = $entity->get('_joinData');
             if ($joinData && $joinData instanceof EntityInterface) {

+ 1 - 1
src/ORM/ResultSet.php

@@ -460,7 +460,7 @@ class ResultSet implements ResultSetInterface
         }
 
         foreach (array_intersect($fields, $schema->columns()) as $col) {
-            $typeName = $schema->columnType($col);
+            $typeName = $schema->getColumnType($col);
             if (isset($typeMap[$typeName])) {
                 $types[$col] = $typeMap[$typeName];
             }

+ 2 - 2
src/ORM/Rule/ExistsIn.php

@@ -117,7 +117,7 @@ class ExistsIn
         if ($this->_options['allowNullableNulls']) {
             $schema = $source->getSchema();
             foreach ($this->_fields as $i => $field) {
-                if ($schema->column($field) && $schema->isNullable($field) && $entity->get($field) === null) {
+                if ($schema->getColumn($field) && $schema->isNullable($field) && $entity->get($field) === null) {
                     unset($bindingKey[$i], $this->_fields[$i]);
                 }
             }
@@ -147,7 +147,7 @@ class ExistsIn
         $nulls = 0;
         $schema = $source->getSchema();
         foreach ($this->_fields as $field) {
-            if ($schema->column($field) && $schema->isNullable($field) && $entity->get($field) === null) {
+            if ($schema->getColumn($field) && $schema->isNullable($field) && $entity->get($field) === null) {
                 $nulls++;
             }
         }

+ 10 - 10
src/ORM/Table.php

@@ -600,7 +600,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
      *
      * ```
      * protected function _initializeSchema(\Cake\Database\Schema\TableSchema $schema) {
-     *  $schema->columnType('preferences', 'json');
+     *  $schema->setColumnType('preferences', 'json');
      *  return $schema;
      * }
      * ```
@@ -626,7 +626,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
     {
         $schema = $this->getSchema();
 
-        return $schema->column($field) !== null;
+        return $schema->getColumn($field) !== null;
     }
 
     /**
@@ -700,10 +700,10 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
             $schema = $this->getSchema();
             $primary = (array)$this->getPrimaryKey();
             $this->_displayField = array_shift($primary);
-            if ($schema->column('title')) {
+            if ($schema->getColumn('title')) {
                 $this->_displayField = 'title';
             }
-            if ($schema->column('name')) {
+            if ($schema->getColumn('name')) {
                 $this->_displayField = 'name';
             }
         }
@@ -1718,7 +1718,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
             '_primary' => true
         ]);
 
-        if ($entity->errors()) {
+        if ($entity->getErrors()) {
             return false;
         }
 
@@ -1737,7 +1737,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
             if ($options['atomic'] || $options['_primary']) {
                 $entity->clean();
                 $entity->isNew(false);
-                $entity->source($this->getRegistryAlias());
+                $entity->setSource($this->getRegistryAlias());
             }
         }
 
@@ -1863,7 +1863,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
         if (!$options['atomic'] && !$options['_primary']) {
             $entity->clean();
             $entity->isNew(false);
-            $entity->source($this->getRegistryAlias());
+            $entity->setSource($this->getRegistryAlias());
         }
 
         return true;
@@ -1901,7 +1901,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
         if (count($primary) > 1) {
             $schema = $this->getSchema();
             foreach ($primary as $k => $v) {
-                if (!isset($data[$k]) && empty($schema->column($k)['autoIncrement'])) {
+                if (!isset($data[$k]) && empty($schema->getColumn($k)['autoIncrement'])) {
                     $msg = 'Cannot insert row, some of the primary key values are missing. ';
                     $msg .= sprintf(
                         'Got (%s), expecting (%s)',
@@ -1930,7 +1930,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
             foreach ($primary as $key => $v) {
                 if (!isset($data[$key])) {
                     $id = $statement->lastInsertId($this->getTable(), $key);
-                    $type = $schema->columnType($key);
+                    $type = $schema->getColumnType($key);
                     $entity->set($key, Type::build($type)->toPHP($id, $driver));
                     break;
                 }
@@ -1959,7 +1959,7 @@ class Table implements RepositoryInterface, EventListenerInterface, EventDispatc
         if (!$primary || count((array)$primary) > 1) {
             return null;
         }
-        $typeName = $this->getSchema()->columnType($primary[0]);
+        $typeName = $this->getSchema()->getColumnType($primary[0]);
         $type = Type::build($typeName);
 
         return $type->newId();

+ 1 - 1
src/TestSuite/Fixture/TestFixture.php

@@ -426,7 +426,7 @@ class TestFixture implements FixtureInterface, TableSchemaInterface, TableSchema
         }
         $fields = array_values(array_unique($fields));
         foreach ($fields as $field) {
-            $types[$field] = $this->_schema->column($field)['type'];
+            $types[$field] = $this->_schema->getColumn($field)['type'];
         }
         $default = array_fill_keys($fields, null);
         foreach ($this->records as $record) {

+ 1 - 1
src/View/Form/EntityContext.php

@@ -552,7 +552,7 @@ class EntityContext implements ContextInterface
     {
         $parts = explode('.', $field);
         $table = $this->_getTable($parts);
-        $column = (array)$table->getSchema()->column(array_pop($parts));
+        $column = (array)$table->getSchema()->getColumn(array_pop($parts));
         $whitelist = ['length' => null, 'precision' => null];
 
         return array_intersect_key($column, $whitelist);