FOF30\Model\DataModel::push PHP Метод

push() публичный Метод

Save a record, creating it if it doesn't exist or updating it if it exists. By default it uses the currently set data, unless you provide a $data array. On top of that, it also saves all specified relations. If $relations is null it will save all relations known to this model.
public push ( null | array $data = null, string $orderingFilter = '', array $ignore = null, array $relations = null )
$data null | array [Optional] Data to bind
$orderingFilter string A WHERE clause used to apply table item reordering
$ignore array A list of fields to ignore when binding $data
$relations array Which relations to save with the model's record. Leave null for all relations
    public function push($data = null, $orderingFilter = '', $ignore = null, array $relations = null)
    {
        // Store the model's $touches definition
        $touches = $this->touches;
        // If $relations is non-null, remove $relations from $this->touches. Since $relations will be saved, they are
        // implicitly touched. We don't want to double-touch those records, do we?
        if (is_array($relations)) {
            $this->touches = array_diff($this->touches, $relations);
        } else {
            $this->touches = array();
        }
        // Save this record
        $this->save($data, $orderingFilter, $ignore, false);
        // Push all relations specified (or all relations if $relations is null)
        $relManager = $this->getRelations();
        $allRelations = $relManager->getRelationNames();
        if (!empty($allRelations)) {
            foreach ($allRelations as $relationName) {
                if (!is_null($relations) && !in_array($relationName, $relations)) {
                    continue;
                }
                $relManager->save($relationName);
            }
        }
        // Restore the model's $touches definition
        $this->touches = $touches;
        // Return self for chaining
        return $this;
    }