protected function addDeleteDescendants(&$script) { $objectClassName = $this->builder->getObjectClassName(); $queryClassName = $this->builder->getQueryClassName(); $tableMapClass = $this->builder->getTableMapClass(); $useScope = $this->behavior->useScope(); $script .= "\n/**\n * Deletes all descendants for the given node\n * Instance pooling is wiped out by this command,\n * so existing {$objectClassName} instances are probably invalid (except for the current one)\n *\n * @param ConnectionInterface \$con Connection to use.\n *\n * @return int number of deleted nodes\n */\npublic function deleteDescendants(ConnectionInterface \$con = null)\n{\n if (\$this->isLeaf()) {\n // save one query\n return;\n }\n if (null === \$con) {\n \$con = Propel::getServiceContainer()->getReadConnection({$tableMapClass}::DATABASE_NAME);\n }\n \$left = \$this->getLeftValue();\n \$right = \$this->getRightValue();"; if ($useScope) { $script .= "\n \$scope = \$this->getScopeValue();"; } $script .= "\n\n return \$con->transaction(function () use (\$con, \$left, \$right" . ($useScope ? ", \$scope" : "") . ") {\n // delete descendant nodes (will empty the instance pool)\n \$ret = {$queryClassName}::create()\n ->descendantsOf(\$this)\n ->delete(\$con);\n\n // fill up the room that was used by descendants\n {$queryClassName}::shiftRLValues(\$left - \$right + 1, \$right, null" . ($useScope ? ", \$scope" : "") . ", \$con);\n\n // fix the right value for the current node, which is now a leaf\n \$this->setRightValue(\$left + 1);\n\n return \$ret;\n });\n}\n"; }
protected function addFilterBySlug(&$script) { $script .= "\n/**\n * Filter the query on the slug column\n *\n * @param string \$slug The value to use as filter.\n *\n * @return \$this|" . $this->builder->getQueryClassName() . " The current query, for fluid interface\n */\npublic function filterBySlug(\$slug)\n{\n return \$this->addUsingAlias(" . $this->builder->getColumnConstant($this->getColumnForParameter('slug_column')) . ", \$slug, Criteria::EQUAL);\n}\n"; }