<commit_before><?php

/*
 *  $Id: PHP5ExtensionQueryBuilder.php 1347 2009-12-03 21:06:36Z francois $
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information please see
 * <http://propel.phpdb.org>.
 */

require_once 'builder/om/OMBuilder.php';

/**
 * Generates the empty PHP5 stub class for object query
 *
 * This class produces the empty stub class that can be customized with application
 * business logic, custom behavior, etc.
 *
 * @author     <NAME>
 * @package    propel.generator.builder.om
 */
class ExtensionQueryBuilder extends OMBuilder
{

	/**
	 * Returns the name of the current class being built.
	 * @return     string
	 */
	public function getUnprefixedClassname()
	{
		return $this->getTable()->getPhpName() . 'Query';
	}

	/**
	 * Adds the include() statements for files that this class depends on or utilizes.
	 * @param      string &$script The script will be modified in this method.
	 */
	protected function addIncludes(&$script)
	{
		$requiredClassFilePath = $this->getQueryBuilder()->getClassFilePath();

		$script .="
require '".$requiredClassFilePath."';
";
	} // addIncludes()

	/**
	 * Adds class phpdoc comment and openning of class.
	 * @param      string &$script The script will be modified in this method.
	 */
	protected function addClassOpen(&$script)
	{
		$table = $this->getTable();
		$tableName = $table->getName();
		$tableDesc = $table->getDescription();
		$baseClassname = $this->getQueryBuilder()->getClassname();

		$script .= "

/**
 * Skeleton subclass for performing query and update operations on the '$tableName' table.
 *
 * $tableDesc
 *";
		if ($this->getBuildProperty('addTimeStamp')) {
			$now = strftime('%c');
			$script .= "
 * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
 *
 * $now
 *";
		}
		$script .= "
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    propel.generator.".$this->getPackage()."
 */
class ".$this->getClassname()." extends $baseClassname {
";
	}

	/**
	 * Specifies the methods that are added as part of the stub query class.
	 *
	 * By default there are no methods for the empty stub classes; override this method
	 * if you want to change that behavior.
	 *
	 * @see        QueryBuilder::addClassBody()
	 */

	protected function addClassBody(&$script)
	{
		$this->addFactory($script);
	}

	/**
	 * Closes class.
	 * @param      string &$script The script will be modified in this method.
	 */
	protected function addClassClose(&$script)
	{
		$script .= "
} // " . $this->getClassname() . "
";
		$this->applyBehaviorModifier('extensionQueryFilter', $script, "");
	}

	/**
	 * Adds the factory for this object.
	 * @param      string &$script The script will be modified in this method.
	 */
	protected function addFactory(&$script)
	{
		$this->addFactoryComment($script);
		$this->addFactoryOpen($script);
		$this->addFactoryBody($script);
		$this->addFactoryClose($script);
	}
	
		/**
	 * Adds the comment for the factory
	 * @param      string &$script The script will be modified in this method.
	 **/
	protected function addFactoryComment(&$script)
	{
		$script .= "
	/**
	 * Returns a new " . $this->getClassname() . " object.
	 *
	 * @param     string \$modelAlias The alias of a model in the query
	 * @param     Criteria \$criteria Optional Criteria to build the query from
	 *
	 * @return    " . $this->getClassname() . "
	 */";
	}

	/**
	 * Adds the function declaration for the factory
	 * @param      string &$script The script will be modified in this method.
	 **/
	protected function addFactoryOpen(&$script)
	{
		$script .= "
	public static function create(\$modelAlias = null, \$criteria = null)
	{";
	}

	/**
	 * Adds the function body for the factory
	 * @param      string &$script The script will be modified in this method.
	 **/
	protected function addFactoryBody(&$script)
	{
		$script .= "
		if (\$criteria instanceof " . $this->getClassname() . ") {
			return \$criteria;
		}
		\$query = new self('" . $this->getTable()->getDatabase()->getName() . "', '" . $this->getTable()->getPhpName() . "', \$modelAlias);
		if (\$criteria instanceof Criteria) {
			\$query->mergeWith(\$criteria);
		}
		return \$query;";
	}

	/**
	 * Adds the function close for the factory
	 * @param      string &$script The script will be modified in this method.
	 **/
	protected function addFactoryClose(&$script)
	{
		$script .= "
	}
";
	}
	
	/**
	 * Checks whether any registered behavior on that table has a modifier for a hook
	 * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
	 * @return boolean
	 */
	public function hasBehaviorModifier($hookName, $modifier = null)
	{
	 	return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier');
	}

	/**
	 * Checks whether any registered behavior on that table has a modifier for a hook<commit_msg>[1.5] Removed hardcoded database connection name in stub query factory (closes #863)<commit_after><?php

/*
 *  $Id: PHP5ExtensionQueryBuilder.php 1347 2009-12-03 21:06:36Z francois $
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information please see
 * <http://propel.phpdb.org>.
 */

require_once 'builder/om/OMBuilder.php';

/**
 * Generates the empty PHP5 stub class for object query
 *
 * This class produces the empty stub class that can be customized with application
 * business logic, custom behavior, etc.
 *
 * @author     <NAME>
 * @package    propel.generator.builder.om
 */
class ExtensionQueryBuilder extends OMBuilder
{

	/**
	 * Returns the name of the current class being built.
	 * @return     string
	 */
	public function getUnprefixedClassname()
	{
		return $this->getTable()->getPhpName() . 'Query';
	}

	/**
	 * Adds the include() statements for files that this class depends on or utilizes.
	 * @param      string &$script The script will be modified in this method.
	 */
	protected function addIncludes(&$script)
	{
		$requiredClassFilePath = $this->getQueryBuilder()->getClassFilePath();

		$script .="
require '".$requiredClassFilePath."';
";
	} // addIncludes()

	/**
	 * Adds class phpdoc comment and openning of class.
	 * @param      string &$script The script will be modified in this method.
	 */
	protected function addClassOpen(&$script)
	{
		$table = $this->getTable();
		$tableName = $table->getName();
		$tableDesc = $table->getDescription();
		$baseClassname = $this->getQueryBuilder()->getClassname();

		$script .= "

/**
 * Skeleton subclass for performing query and update operations on the '$tableName' table.
 *
 * $tableDesc
 *";
		if ($this->getBuildProperty('addTimeStamp')) {
			$now = strftime('%c');
			$script .= "
 * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
 *
 * $now
 *";
		}
		$script .= "
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    propel.generator.".$this->getPackage()."
 */
class ".$this->getClassname()." extends $baseClassname {
";
	}

	/**
	 * Specifies the methods that are added as part of the stub query class.
	 *
	 * By default there are no methods for the empty stub classes; override this method
	 * if you want to change that behavior.
	 *
	 * @see        QueryBuilder::addClassBody()
	 */

	protected function addClassBody(&$script)
	{
		$this->addFactory($script);
	}

	/**
	 * Closes class.
	 * @param      string &$script The script will be modified in this method.
	 */
	protected function addClassClose(&$script)
	{
		$script .= "
} // " . $this->getClassname() . "
";
		$this->applyBehaviorModifier('extensionQueryFilter', $script, "");
	}

	/**
	 * Adds the factory for this object.
	 * @param      string &$script The script will be modified in this method.
	 */
	protected function addFactory(&$script)
	{
		$this->addFactoryComment($script);
		$this->addFactoryOpen($script);
		$this->addFactoryBody($script);
		$this->addFactoryClose($script);
	}
	
		/**
	 * Adds the comment for the factory
	 * @param      string &$script The script will be modified in this method.
	 **/
	protected function addFactoryComment(&$script)
	{
		$script .= "
	/**
	 * Returns a new " . $this->getClassname() . " object.
	 *
	 * @param     string \$modelAlias The alias of a model in the query
	 * @param     Criteria \$criteria Optional Criteria to build the query from
	 *
	 * @return    " . $this->getClassname() . "
	 */";
	}

	/**
	 * Adds the function declaration for the factory
	 * @param      string &$script The script will be modified in this method.
	 **/
	protected function addFactoryOpen(&$script)
	{
		$script .= "
	public static function create(\$modelAlias = null, \$criteria = null)
	{";
	}

	/**
	 * Adds the function body for the factory
	 * @param      string &$script The script will be modified in this method.
	 **/
	protected function addFactoryBody(&$script)
	{
		$script .= "
		if (\$criteria instanceof " . $this->getClassname() . ") {
			return \$criteria;
		}
		\$query = new self();
		if (null !== \$modelAlias) {
			\$query->setModelalias(\$modelAlias);
		}
		if (\$criteria instanceof Criteria) {
			\$query->mergeWith(\$criteria);
		}
		return \$query;";
	}

	/**
	 * Adds the function close for the factory
	 * @param      string &$script The script will be modified in this method.
	 **/
	protected function addFactoryClose(&$script)
	{
		$script .= "
	}
";
	}
	
	/**
	 * Checks whether any registered behavior on that table has a modifier for a hook
	 * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
	 * @return boolean
	 */
	public function hasBehaviorModifier($hookName, $modifier = null)
	{
	 	return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier');
	}

	/**
	 * Checks whether any registered behavior on that table has a modifier for a hook
{'fraction_non_alphanumeric': 0.12020743007736122, 'fraction_numerical': 0.0038255547054322878, 'mean_word_length': 3.5021048603138154, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5389642', 'n_tokens_mistral': 3653, 'n_tokens_neox': 3292, 'n_words': 1229}