protected function addRootsOf(&$script)
 {
     $objectName = '$' . $this->table->getCamelCaseName();
     $script .= "\n/**\n * Filter the query to restrict the result to roots of an object.\n * Same as ancestorsOf(), except that it includes the object passed as parameter in the result\n *\n * @param     {$this->objectClassName} {$objectName} The object to use for roots search\n *\n * @return    \$this|{$this->queryClassName} The current query, for fluid interface\n */\npublic function rootsOf({$this->objectClassName} {$objectName})\n{\n    return \$this";
     if ($this->behavior->useScope()) {
         $script .= "\n        ->inTree({$objectName}->getScopeValue())";
     }
     $script .= "\n        ->addUsingAlias({$this->objectClassName}::LEFT_COL, {$objectName}->getLeftValue(), Criteria::LESS_EQUAL)\n        ->addUsingAlias({$this->objectClassName}::RIGHT_COL, {$objectName}->getRightValue(), Criteria::GREATER_EQUAL);\n}\n";
 }
 public function testSetCustomPhpName()
 {
     $table = new Table('created_at');
     $table->setPhpName('CreatedAt');
     $this->assertSame('CreatedAt', $table->getPhpName());
     $this->assertSame('createdAt', $table->getCamelCaseName());
 }
Example #3
0
 /**
  * Adds the switch-statement for looking up the array-key name for toArray
  * @see toArray
  */
 protected function addToArrayKeyLookUp($phpName, Table $table, $plural)
 {
     if ($phpName == "") {
         $phpName = $table->getPhpName();
     }
     $camelCaseName = $table->getCamelCaseName();
     $fieldName = $table->getName();
     if ($plural) {
         $phpName = $this->getPluralizer()->getPluralForm($phpName);
         $camelCaseName = $this->getPluralizer()->getPluralForm($camelCaseName);
         $fieldName = $this->getPluralizer()->getPluralForm($fieldName);
     }
     return "\n                switch (\$keyType) {\n                    case TableMap::TYPE_CAMELNAME:\n                        \$key = '" . $camelCaseName . "';\n                        break;\n                    case TableMap::TYPE_FIELDNAME:\n                        \$key = '" . $fieldName . "';\n                        break;\n                    default:\n                        \$key = '" . $phpName . "';\n                }\n        ";
 }
 protected function addNestedSetChildAdd(&$script)
 {
     $objectClassName = $this->builder->getObjectClassName();
     $objectName = '$' . $this->table->getCamelCaseName();
     $script .= "\n/**\n * Adds an element to the internal \$collNestedSetChildren collection.\n * Beware that this doesn't insert a node in the tree.\n * This method is only used to facilitate children hydration.\n *\n * @param      {$objectClassName} {$objectName}\n *\n * @return     void\n */\npublic function addNestedSetChild({$objectClassName} {$objectName})\n{\n    if (null === \$this->collNestedSetChildren) {\n        \$this->initNestedSetChildren();\n    }\n    if (!in_array({$objectName}, \$this->collNestedSetChildren->getArrayCopy(), true)) { // only add it if the **same** object is not already associated\n        \$this->collNestedSetChildren[]= {$objectName};\n        {$objectName}->setParent(\$this);\n    }\n}\n";
 }