/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this SchemaProperty has previously * been saved, it will retrieve related SchemaPropertyElementsRelatedByRelatedSchemaPropertyId from storage. * If this SchemaProperty is new, it will return * an empty collection or the current collection, the criteria * is ignored on a new object. * * @param Connection $con * @param Criteria $criteria * @throws PropelException */ public function getSchemaPropertyElementsRelatedByRelatedSchemaPropertyId($criteria = null, $con = null) { // include the Peer class include_once 'lib/model/om/BaseSchemaPropertyElementPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collSchemaPropertyElementsRelatedByRelatedSchemaPropertyId === null) { if ($this->isNew()) { $this->collSchemaPropertyElementsRelatedByRelatedSchemaPropertyId = array(); } else { $criteria->add(SchemaPropertyElementPeer::RELATED_SCHEMA_PROPERTY_ID, $this->getId()); SchemaPropertyElementPeer::addSelectColumns($criteria); $this->collSchemaPropertyElementsRelatedByRelatedSchemaPropertyId = SchemaPropertyElementPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(SchemaPropertyElementPeer::RELATED_SCHEMA_PROPERTY_ID, $this->getId()); SchemaPropertyElementPeer::addSelectColumns($criteria); if (!isset($this->lastSchemaPropertyElementRelatedByRelatedSchemaPropertyIdCriteria) || !$this->lastSchemaPropertyElementRelatedByRelatedSchemaPropertyIdCriteria->equals($criteria)) { $this->collSchemaPropertyElementsRelatedByRelatedSchemaPropertyId = SchemaPropertyElementPeer::doSelect($criteria, $con); } } } $this->lastSchemaPropertyElementRelatedByRelatedSchemaPropertyIdCriteria = $criteria; return $this->collSchemaPropertyElementsRelatedByRelatedSchemaPropertyId; }
/** * gets repeatable or unused profile properties for a resource property element * * @return array * @param criteria $criteria */ public static function getProfilePropertiesForCreate($criteria = null) { if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } //get the current property ID //create should always have a property id $propertyId = sfContext::getInstance()->getRequest()->getParameter('schema_property_id'); //get the current property if ($propertyId) { $schemaProperty = SchemaPropertyPeer::retrieveByPK($propertyId); if ('class' == $schemaProperty->getType() || 'subclass' == $schemaProperty->getType()) { $criteria->add(ProfilePropertyPeer::IS_IN_CLASS_PICKLIST, 1); } else { $criteria->add(ProfilePropertyPeer::IS_IN_PROPERTY_PICKLIST, 1); } } //properties for the metadata registry schema are currently related to profile '1' $criteria->add(ProfilePropertyPeer::PROFILE_ID, 1); $criteria->add(ProfilePropertyPeer::IS_IN_PICKLIST, 1); $criteria->addAscendingOrderByColumn(ProfilePropertyPeer::URI); //get the list of all properties for this profile/namespace //at some point this should look at the property or schema namespace $profileProperties = self::doSelect($criteria); $propertyList = array(); $pickList = array(); foreach ($profileProperties as $key => $property) { $propertyList[$property->getId()] = $property; $pickList[$property->getId()] = $property->getLabel(); } //get the property elements already in use for this property $c = new Criteria(); $c->add(SchemaPropertyElementPeer::SCHEMA_PROPERTY_ID, $propertyId); $c->add(SchemaPropertyElementPeer::IS_SCHEMA_PROPERTY, true); $elements = SchemaPropertyElementPeer::doSelect($c); foreach ($elements as $key => $element) { $propertyId = $element->getProfilePropertyId(); //if the property is in the list and not repeatable /** @var ProfileProperty **/ if (isset($propertyList[$propertyId]) && $propertyList[$propertyId]->getIsSingleton()) { //remove it from the list of all properties unset($pickList[$propertyId]); unset($propertyList[$propertyId]); } } return $propertyList; //whatever remains in the list }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param Connection $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(SchemaPropertyElementPeer::ID, $pks, Criteria::IN); $objs = SchemaPropertyElementPeer::doSelect($criteria, $con); } return $objs; }