store nestable node

@param $class
@param string|null $path
@param integer|null $id
@throws StoreException
@return array
975583
protected function storeNode($class, $path = null, $id = null)
    {
        DB::beginTransaction();
        try {
            $datas = $this->request->parent != 0 || $this->request->related != 0 ? $this->getDefineDatas($class) : $this->request->all();
            $this->model = $class::create($datas);
            $this->model->setNode($class, $this->request);

            // eğer başka ilişki varsa onları da ekle
            if ($this->opsRelation && ! $this->fillModel($this->opsRelation)) {
                throw new StoreException($this->request->all());
            }

            event(new $this->events['success']($this->model));
            DB::commit();

            if (is_null($path)) {
                $attribute = "{$this->name}_uc_first";
                return response()->json([
                    'id' => $this->model->id,
                    'name' => $this->model->$attribute
                ]);
            }

            Flash::success(trans('laravel-modules-base::admin.flash.store_success'));
            return $this->redirectRoute($path);
        } catch (StoreException $e) {
            DB::rollback();
            event(new $this->events['fail']($e->getDatas()));

            if (is_null($path)) {
                return response()->json($this->returnData('error'));
            }
            Flash::error(trans('laravel-modules-base::admin.flash.store_error'));
            return $this->redirectRoute($path);
        }
    }
918380
public function create($class, $id, $path, $label, $permission, $options = [])
    {
        foreach ($this->itemFactories as $itemFactory) {
            if ($itemFactory->supports($class)) {
                return $itemFactory->build($class, $id, $path, $label, $permission, $options);
            }
        }
    }
617416
public function deleteNode( $id = null )
	{
		$node = $this->getNode( $id, MW_Tree_Manager_Abstract::LEVEL_ONE );

		$conn = $this->_dbm->acquire( $this->_dbname );

		try
		{
			$stmt = $conn->create( $this->_config['delete'] );
			$stmt->bind( 1, $node->left, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->bind( 2, $node->right, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->execute()->finish();

			$diff = $node->right - $node->left + 1;

			$stmt = $conn->create( $this->_config['move-left'] );
			$stmt->bind( 1, -$diff, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->bind( 2, 0, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->bind( 3, $node->right + 1, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->bind( 4, 0x7FFFFFFF, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->execute()->finish();

			$stmt = $conn->create( $this->_config['move-right'] );
			$stmt->bind( 1, -$diff, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->bind( 2, $node->right + 1, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->bind( 3, 0x7FFFFFFF, MW_DB_Statement_Abstract::PARAM_INT );
			$stmt->execute()->finish();

			$this->_dbm->release( $conn, $this->_dbname );
		}
		catch( Exception $e )
		{
			$this->_dbm->release( $conn, $this->_dbname );
			throw $e;
		}
	}
532495
public function storeElement($project, $element, $child, $elementName = null)
    {
        if ($elementName === null) {
            return;
        }

        $storer = "addconfigured" . strtolower($elementName);

        if (isset($this->nestedStorers[$storer])) {
            $method = $this->nestedStorers[$storer];

            try {
                $project->log(
                    "    -calling storer " . $method->getDeclaringClass()->getName() . "::" . $method->getName() . "()",
                    Project::MSG_DEBUG
                );
                $method->invoke($element, $child);
            } catch (Exception $exc) {
                throw new BuildException($exc->getMessage(), $exc);
            }
        }
    }
926957
private function loadParams($path, \DOMXPath $xpath, \DOMNode $context = null)
    {
        $result = [];

        /** @var \DOMElement $node */
        foreach ($xpath->query($path, $context) as $node) {
            $result[] = $this->loadParam($xpath, $node);
        }

        return $result;
    }
352844
final public function set(string $id, string $class = null): ServiceConfigurator
    {
        $this->__destruct();

        return $this->parent->set($id, $class);
    }
1235064
public function archive(?string $id, string $path)
    {
        $url = self::$base_url.'/'.($id ?? $this->container_id).'/archive?'.http_build_query(['path' => $path]);

        return self::$curl->get($url);
    }
1031180
protected function getClassXType($root, $class, $path)
    {
        if ($type = $this->getFromCache($class, $path)) {
            return $type;
        }

        $root = is_object($root) ? $root : new $root;

        // If the class is in cache but not the specific path
        if (isset($this->classCache[$class])) {
            return null;
        }

        $classType = $root instanceof SelfExplanatory ?
                        $this->typeFactory->toType($root) :
                        $this->getFromExtension($class);

        if ($classType) {
            $this->putAllIntoCache($class, $classType);
            return $path ? $this->getClassXType($root, $class, $path) : $classType;
        }

        return null;
    }
600011
protected function getOrCreateByPath($path, EloquentFile $parentNode=null)
    {
        $node = $this->getOrMakeByPath($path, $parentNode);

        if (!$node->getId()) {
            $this->save($node);
        }

        return $node;

    }
862731
public static function setByPath(&$data, $path, $value, $separator = '.', $storeType = 'array')
	{
		$nodes = array_values(array_filter(explode($separator, $path), 'strlen'));

		if (empty($nodes))
		{
			return false;
		}

		/**
		 * A closure as inner function to create data store.
		 *
		 * @param string $type
		 *
		 * @return  array
		 *
		 * @throws \InvalidArgumentException
		 */
		$createStore = function($type)
		{
			if (strtolower($type) == 'array')
			{
				return array();
			}

			if (class_exists($type))
			{
				return new $type;
			}

			throw new \InvalidArgumentException(sprintf('Type or class: %s not exists', $type));
		};

		$dataTmp = &$data;

		foreach ($nodes as $node)
		{
			if (is_object($dataTmp))
			{
				if (empty($dataTmp->$node))
				{
					$dataTmp->$node = $createStore($storeType);
				}

				$dataTmp = &$dataTmp->$node;
			}
			elseif (is_array($dataTmp))
			{
				if (empty($dataTmp[$node]))
				{
					$dataTmp[$node] = $createStore($storeType);
				}

				$dataTmp = &$dataTmp[$node];
			}
			else
			{
				// If a node is value but path is not go to the end, we replace this value as a new store.
				// Then next node can insert new value to this store.
				$dataTmp = &$createStore($storeType);
			}
		}

		// Now, path go to the end, means we get latest node, set value to this node.
		$dataTmp = $value;

		return true;
	}
541996
public function convert($data, string $path = '', bool $allowSerializeEmpty = false): AbstractParentNode
    {
        if (!is_array($data) && !$data instanceof \Traversable) {
            throw new \InvalidArgumentException(sprintf('Params need to be array or %s', \Traversable::class));
        }

        $isArray = $this->isArray($data);
        $parentNode = $this->getParentNode($isArray, $allowSerializeEmpty);

        foreach ($data as $key => $value) {
            $this->addChildNode($parentNode, $key, $value, $path, $isArray, $allowSerializeEmpty);
        }

        return $parentNode;
    }
597379
public function fetchAllObj(string $class = null): array
    {
        if ($class == null && $this->modelClass !== null) {
            return parent::fetchAllObj($this->modelClass);
        } else {
            return parent::fetchAllObj($class);
        }
    }
217101
public function store($updateNulls = false)
    {
        $k = $this->getKeyName();

        /*
         * If the primary key is empty, then we assume we are inserting a new node into the
         * tree.  From this point we would need to determine where in the tree to insert it.
         */
        if (empty($this->$k)) {
            /*
             * We are inserting a node somewhere in the tree with a known reference
             * node.  We have to make room for the new node and set the left and right
             * values before we insert the row.
             */
            if ($this->locationId < 0) {
                // Negative parent ids are invalid
                throw new NestedHandleException(sprintf('%s::store() used a negative _location_id', get_class($this)));
            }

            // We are inserting a node relative to the last root node.
            if ($this->locationId == 0) {
                // Get the last root node as the reference node.
                $query = $this->db->getQuery(true)
                    ->select($this->getKeyName() . ', parent_id, level, lft, rgt')
                    ->from($this->db->quoteName($this->table))
                    ->where('parent_id = 0')
                    ->order('lft DESC')
                    ->limit(1);

                $this->db->setQuery($query);

                $reference = $this->db->loadOne();
            } else {
                // We have a real node set as a location reference.
                // Get the reference node by primary key.
                if (!$reference = $this->getNode($this->locationId)) {
                    throw new NestedHandleException('Cannot get node by location id: ' . $this->locationId);
                }
            }

            // Get the reposition data for shifting the tree and re-inserting the node.
            if (!($repositionData = $this->getTreeRepositionData($reference, 2, $this->location))) {
                throw new NestedHandleException('Cannot get reposition data.');
            }

            // Create space in the tree at the new location for the new node in left ids.
            $query = $this->db->getQuery(true)
                ->update($this->db->quoteName($this->table))
                ->set('lft = lft + 2')
                ->where($repositionData->left_where);

            $this->db->setQuery($query)->execute();

            // Create space in the tree at the new location for the new node in right ids.
            $query->clear()
                ->update($this->db->quoteName($this->table))
                ->set('rgt = rgt + 2')
                ->where($repositionData->right_where);

            $this->db->setQuery($query)->execute();

            // Set the object values.
            $this->parent_id = $repositionData->new_parent_id;
            $this->level = $repositionData->new_level;
            $this->lft = $repositionData->new_lft;
            $this->rgt = $repositionData->new_rgt;
        } else {
            /*
             * If we have a given primary key then we assume we are simply updating this
             * node in the tree.  We should assess whether or not we are moving the node
             * or just updating its data fields.
             */

            // If the location has been set, move the node to its new location.
            if ($this->locationId > 0) {
                $this->moveByReference($this->locationId, $this->location, $this->$k);
            }
        }

        return parent::store($updateNulls);
    }
257634
public function registerFromPath($id, $path){
		if( !file_exists($path) ){
			return false;
		}
		$dom = $this->parser->parseFromString(file_get_contents($path));
		if( $dom ){
			$this->doms[$id] = $dom;
		}
		return false;
	}
1005038
private Array store(Class clazz) {
	Constructor[] conArr = clazz.getConstructors();
	Array args = new ArrayImpl();
	for (int i = 0; i < conArr.length; i++) {
	    storeArgs(conArr[i], args);
	}
	map.put(clazz, args);
	return args;

    }
577285
function factory($id,$row) {
		$mapper=clone($this);
		$mapper->reset();
		$mapper->id=$id;
		foreach ($row as $field=>$val)
			$mapper->document[$field]=$val;
		$mapper->query=[clone($mapper)];
		if (isset($mapper->trigger['load']))
			\Base::instance()->call($mapper->trigger['load'],$mapper);
		return $mapper;
	}
1356998
public function generate($document, ClassMetadata $class, DocumentManagerInterface $dm, $parent = null)
    {
        if (null === $parent) {
            $parent = $class->parentMapping ? $class->getFieldValue($document, $class->parentMapping) : null;
        }

        $id = $class->getFieldValue($document, $class->identifier);
        if (empty($id) && null === $parent) {
            throw IdException::noIdNoParent($document, $class->parentMapping);
        }

        if (empty($parent)) {
            return $id;
        }

        try {
            $parentNode = $dm->getNodeForDocument($parent);
            $existingNames = (array) $parentNode->getNodeNames();
        } catch (RepositoryException $e) {
            // this typically happens while cascading persisting documents
            $existingNames = [];
        }
        $name = NodeHelper::generateAutoNodeName(
            $existingNames,
            $dm->getPhpcrSession()->getWorkspace()->getNamespaceRegistry()->getNamespaces(),
            '',
            ''
        );

        return $this->buildName($document, $class, $dm, $parent, $name);
    }