本文整理汇总了PHP中BaseObject::getByName方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseObject::getByName方法的具体用法?PHP BaseObject::getByName怎么用?PHP BaseObject::getByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseObject
的用法示例。
在下文中一共展示了BaseObject::getByName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAndConfigureForm
/**
* Create and configure forn
*
* @param string $formClassName
* @author Łukasz Wojciechowski
*/
public function createAndConfigureForm($formClassName)
{
$this->form = new $formClassName($this->object);
$vs = $this->form->getValidatorSchema();
foreach ($vs->getFields() as $fieldName => $validator) {
$this->form->setValidator($fieldName, new sfValidatorPass());
}
if (isset($this->form['id'])) {
unset($this->form['id']);
}
$formFieldNames = $this->getFieldNamesOfForm($this->form);
$this->form->useFields($formFieldNames);
// making form field default values available for widget XML config file placeholders
foreach ($formFieldNames as $fieldName) {
if (!in_array($fieldName, $this->deprecated_placeholders)) {
$this->{$fieldName} = $this->object->getByName($fieldName, BasePeer::TYPE_FIELDNAME);
}
}
}
示例2: comparePropelObjectsByFields
/**
*
* Compares two propel objects and notifies the PHPUnit / Kaltura's listeners
* @param BaseObject $outputReference
* @param BaseObject $newResult
* @return array<> $newErrors, if the objects are equal
*/
public function comparePropelObjectsByFields($outputReference, $newResult, $validErrorFields)
{
//Gets the data peer of the object (used to geting all the obejct feilds)
$dataPeer = $outputReference->getPeer();
$outputReferenceId = $outputReference->getId();
$newResultId = $newResult->getId();
//Gets all object feilds
$fields = call_user_func(array($dataPeer, "getFieldNames"), BasePeer::TYPE_PHPNAME);
$newErrors = array();
//Create the xml elements by all fields and their values
foreach ($fields as $field) {
PHP_Timer::start();
//If the field is in the valid failure list then we skip him
if (in_array($field, $validErrorFields)) {
continue;
} else {
$expectedValue = $outputReference->getByName($field);
$actualValue = $newResult->getByName($field);
//if this is an array we need to change it to a string
$this->compareOnField($field, $actualValue, $expectedValue, "assertEquals");
}
}
return $newErrors;
}
示例3: getParamListFromObjectAsArray
public static function getParamListFromObjectAsArray(BaseObject $obj, $param_names)
{
if ($obj == NULL) {
return NULL;
}
if (!$obj instanceof BaseObject) {
throw new Exception("getParamFromObject should have the first parameter an object of type BaseObject");
}
$res = array();
foreach ($param_names as $param_name) {
$res[$param_name] = $obj->getByName($param_name, BasePeer::TYPE_FIELDNAME);
}
return $res;
}
示例4: relatedTo
/**
* Finder fluid method to restrict results to a related object
* Examples:
* $commentFinder->relatedTo($article)
* => $c->add(CommentPeer::ARTICLE_ID, $article->getId())
*
* @param BaseObject $object The related object to restrict to
* @return sfPropelFinder the current finder object
*/
public function relatedTo($object)
{
// looking for a 1-n relationship
$relatedObjectTableName = $object->getPeer()->getTableMap()->getName();
foreach (sfPropelFinderUtils::getColumnsForPeerClass($this->peerClass) as $c) {
if ($c->getRelatedTableName() == $relatedObjectTableName) {
$this->addCondition('and', $c->getFullyQualifiedName(), $object->getByName($c->getRelatedName(), BasePeer::TYPE_COLNAME), Criteria::EQUAL);
return $this;
}
}
// looking for a n-1 relationship
$localObjectTableName = $this->object->getPeer()->getTableMap()->getName();
foreach (sfPropelFinderUtils::getColumnsForPeerClass(get_class($object->getPeer())) as $c) {
if ($c->getRelatedTableName() == $localObjectTableName) {
$this->addCondition('and', $c->getRelatedName(), $object->getByName($c->getFullyQualifiedName(), BasePeer::TYPE_COLNAME), Criteria::EQUAL);
return $this;
}
}
throw new Exception('Could not find a relation with object of class ' . get_class($object));
}