Browse Source

Merge pull request #13324 from cakephp/3.next-backport-from-v4

Backport 4.x deprecations for easier upgrading.
Mark Story 6 years ago
parent
commit
26f2bb82e7
1 changed files with 24 additions and 4 deletions
  1. 24 4
      src/Datasource/EntityTrait.php

+ 24 - 4
src/Datasource/EntityTrait.php

@@ -556,7 +556,7 @@ trait EntityTrait
     }
 
     /**
-     * Get the list of visible properties.
+     * Gets the list of visible properties.
      *
      * The list of visible properties is all standard properties
      * plus virtual properties minus hidden properties.
@@ -564,7 +564,7 @@ trait EntityTrait
      * @return array A list of properties that are 'visible' in all
      *     representations.
      */
-    public function visibleProperties()
+    public function getVisible()
     {
         $properties = array_keys($this->_properties);
         $properties = array_merge($properties, $this->_virtual);
@@ -573,6 +573,26 @@ trait EntityTrait
     }
 
     /**
+     * Gets the list of visible properties.
+     *
+     * The list of visible properties is all standard properties
+     * plus virtual properties minus hidden properties.
+     *
+     * @return array A list of properties that are 'visible' in all
+     *     representations.
+     * @deprecated 3.8.0 Use getVisible() instead.
+     */
+    public function visibleProperties()
+    {
+        deprecationWarning(
+            get_called_class() . '::visibleProperties() is deprecated. ' .
+            'Use getVisible() instead.'
+        );
+
+        return $this->getVisible();
+    }
+
+    /**
      * Returns an array with all the properties that have been set
      * to this entity
      *
@@ -584,7 +604,7 @@ trait EntityTrait
     public function toArray()
     {
         $result = [];
-        foreach ($this->visibleProperties() as $property) {
+        foreach ($this->getVisible() as $property) {
             $value = $this->get($property);
             if (is_array($value)) {
                 $result[$property] = [];
@@ -612,7 +632,7 @@ trait EntityTrait
      */
     public function jsonSerialize()
     {
-        return $this->extract($this->visibleProperties());
+        return $this->extract($this->getVisible());
     }
 
     /**