Example #1
0
 /**
  * Storage component. Global container is required!
  *
  * @return StorageInterface
  */
 private function storage()
 {
     if (!empty($this->storage)) {
         return $this->storage;
     }
     if (!empty($this->parent) && $this->parent instanceof Component) {
         return $this->storage = $this->parent->container()->get(StorageInterface::class);
     }
     //Only when global container is set and no parent container specified
     return $this->storage = self::staticContainer()->get(StorageInterface::class);
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getErrors($reset = true)
 {
     //De-mapping
     $errors = [];
     foreach (parent::getErrors($reset) as $field => $errorSet) {
         list(, $origin) = $this->parseSource($field, $this->schema[$field]);
         if ($field == $origin) {
             $errors[$field] = $errorSet;
         } else {
             //Let's recreate original structure
             $this->dotSet($errors, $origin, $errorSet);
         }
     }
     return $errors;
 }
Example #3
0
 /**
  * Update ORM records schema, synchronize declared and database schemas and return instance of
  * SchemaBuilder.
  *
  * @param SchemaBuilder $builder User specified schema builder.
  * @return SchemaBuilder
  */
 public function updateSchema(SchemaBuilder $builder = null)
 {
     $builder = !empty($builder) ? $builder : $this->schemaBuilder();
     //Casting relations between records
     $builder->castRelations();
     //Create all required tables and columns
     $builder->synchronizeSchema();
     //Saving
     $this->memory->saveData(static::SCHEMA_SECTION, $this->schema = $builder->normalizeSchema());
     //Let's reinitialize records
     DataEntity::resetInitiated();
     return $builder;
 }
Example #4
0
 /**
  * Update ODM documents schema and return instance of SchemaBuilder.
  *
  * @param SchemaBuilder $builder User specified schema builder.
  * @return SchemaBuilder
  */
 public function updateSchema(SchemaBuilder $builder = null)
 {
     $builder = !empty($builder) ? $builder : $this->schemaBuilder();
     //We will create all required indexes now
     $builder->createIndexes();
     //Saving
     $this->memory->saveData(static::SCHEMA_SECTION, $this->schema = $builder->normalizeSchema());
     //Let's reinitialize models
     DataEntity::resetInitiated();
     return $builder;
 }
Example #5
0
 /**
  * Update ORM records schema, synchronize declared and database schemas and return instance of
  * SchemaBuilder.
  *
  * @param SchemaBuilder $builder    User specified schema builder.
  * @param bool          $syncronize Create all required tables and columns
  * @return SchemaBuilder
  */
 public function updateSchema(SchemaBuilder $builder = null, $syncronize = false)
 {
     if (empty($builder)) {
         $builder = $this->schemaBuilder();
     }
     //Create all required tables and columns
     if ($syncronize) {
         $builder->synchronizeSchema();
     }
     //Getting normalized (cached) version of schema
     $this->schema = $builder->normalizeSchema();
     //Saving
     $this->memory->saveData(static::MEMORY, $this->schema);
     //Let's reinitialize records
     DataEntity::resetInitiated();
     return $builder;
 }
 /**
  * {@inheritdoc}
  */
 protected function createValidator(array $rules = [], ContainerInterface $container = null)
 {
     //Initiate validation using rules declared in model schema
     return parent::createValidator(!empty($rules) ? $rules : $this->schema[self::SH_VALIDATES], $container);
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 public function validator(array $rules = [], ContainerInterface $container = null)
 {
     //Initiate validation using rules declared in odmSchema
     return parent::validator(!empty($rules) ? $rules : $this->schema[self::SH_VALIDATES], $container);
 }
Example #8
0
 /**
  * Update ODM documents schema and return instance of SchemaBuilder.
  *
  * @param SchemaBuilder $builder User specified schema builder.
  * @param bool          $createIndexes
  * @return SchemaBuilder
  */
 public function updateSchema(SchemaBuilder $builder = null, $createIndexes = false)
 {
     if (empty($builder)) {
         $builder = $this->schemaBuilder();
     }
     //We will create all required indexes now
     if ($createIndexes) {
         $builder->createIndexes();
     }
     //Getting cached/normalized schema
     $this->schema = $builder->normalizeSchema();
     //Saving
     $this->memory->saveData(static::MEMORY, $this->schema);
     //Let's reinitialize models
     DataEntity::resetInitiated();
     return $builder;
 }