]> _ Git - cubist_cms-back.git/commitdiff
wip #3753 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 10 Dec 2020 19:36:18 +0000 (20:36 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 10 Dec 2020 19:36:18 +0000 (20:36 +0100)
src/app/Magic/Fields/Field.php

index ac7792266649a5ad35ae9b6cdc7825bfc29d2246..4e3c54d52538418dff060f26fe562d93a1e08e2a 100644 (file)
@@ -43,6 +43,7 @@ class Field implements \ArrayAccess
     protected $_migrateTranslatable = false;
 
     protected $_can = null;
+    protected $_canWrite = null;
     protected $_auth = true;
 
     /**
@@ -119,7 +120,7 @@ class Field implements \ArrayAccess
             'preview' => $this->_preview, 'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat,
             'default' => '', 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic,
             'allow_null' => true,
-            'can' => $this->_can, 'auth' => $this->_auth,
+            'can' => $this->_can, 'can_write' => $this->_canWrite, 'auth' => $this->_auth,
             'database_unique' => $this->_databaseUnique, 'database_index' => $this->_databaseIndex,
             'fake' => false, 'store_in' => 'extras', 'attributes' => []];
     }
@@ -301,6 +302,13 @@ class Field implements \ArrayAccess
                 $this->setAttribute('view_namespace', CubistBackpackServiceProvider::NAMESPACE . '::fields');
             }
         }
+
+        if (null !== $this->getAttribute('can_write', null)) {
+            if (!can($this->getAttribute('can_write'))) {
+                $this->setAttribute('type', 'static');
+                $this->setAttribute('view_namespace', CubistBackpackServiceProvider::NAMESPACE . '::fields');
+            }
+        }
     }
 
     /**