/** * Displays the list of existing job queues. * * @param array $arguments (optional) * @param array $options (optional) */ public function execute($arguments = array(), $options = array()) { if ($arguments["src"] === "none") { $arguments["src"] = null; } if ($arguments["reporting"] != "full" && $arguments["reporting"] != "incremental" && $arguments["reporting"] != "cache" && $arguments["reporting"] != "file") { throw new Exception("Invalid value for argument: reporting. The value 'incremental', 'cache', 'file' or 'full' are expected, but '" . $arguments["reporting"] . "' is given!"); } else { if ($arguments["rebuild"] != "yes" && $arguments["rebuild"] != "no") { throw new Exception("Invalid value for argument: rebuild. The value 'yes' or 'no' are expected, but '" . $arguments["rebuild"] . "' is given!"); } else { if ($arguments["src"] != null && (!file_exists($arguments["src"]) || !is_readable($arguments["src"]))) { throw new Exception("Invalid value for argument: src. The file '" . $arguments["src"] . "' doesn't exist or is not readable!"); } } } $project = ProjectConfiguration::getActive(); $this->basedir = $project->getRootDir(); // Add plugin dirs.. $this->dirs = XmlParser::getPluginDirs($this->basedir . "/plugins"); // DB $this->dbmanager = new sfDatabaseManager($this->configuration); // XML Validator $this->validator = new XmlValidator(null, false, true, $arguments["reporting"] == "cache"); // Truncating cache if ($arguments["rebuild"] == "yes") { afValidatorCachePeer::clearCache(); } if ($arguments["log"] !== null) { $this->log = $arguments["log"]; } $this->args = $arguments; $this->logSection("\nXML Config validation is starting.. (this may take a while)\n" . "Validation type: " . $arguments["reporting"] . " \n" . "Will flush cache: " . $arguments["rebuild"] . " ", null, null, "ERROR"); if ($arguments["reporting"] != "file" && $arguments["src"] == null) { foreach ($this->dirs as $dir) { $scan = substr($dir, 0, 1) == "/" ? $dir : $this->basedir . "/apps/" . $arguments['application'] . "/" . $dir; $this->readConfigs($scan); } } else { $this->validator->readXmlDocument($arguments["src"], true); $result = $this->validator->validateXmlDocument(true); $this->logSection($result[1] === null ? "valid: " : "error: ", $arguments["src"], null, $result[0]); if ($result[1]) { echo Util::arrayToString(array("file" => $tmp, "message" => $result[1]->getMessage())); return true; } } if ($arguments["reporting"] == "full") { $this->printTotal(); } return 0; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(afValidatorCachePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(afValidatorCachePeer::DATABASE_NAME); $criteria->add(afValidatorCachePeer::ID, $pks, Criteria::IN); $objs = afValidatorCachePeer::doSelect($criteria, $con); } return $objs; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = afValidatorCachePeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setSignature($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setPath($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setCreatedAt($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setUpdatedAt($arr[$keys[4]]); } }
/** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. * * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * * @return afValidatorCache A model object, or null if the key is not found */ protected function findPkSimple($key, $con) { $sql = 'SELECT `ID`, `SIGNATURE`, `PATH`, `CREATED_AT`, `UPDATED_AT` FROM `af_validator_cache` WHERE `ID` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); } $obj = null; if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $obj = new afValidatorCache(); $obj->hydrate($row); afValidatorCachePeer::addInstanceToPool($obj, (string) $row[0]); } $stmt->closeCursor(); return $obj; }
private function putCache($obj = null) { afValidatorCachePeer::putCache($this->hash, $this->file, $obj); }
public function readXmlDocument($path = null, $security = false, $uri = false) { $page = false; if (!$uri) { $action = sfContext::getInstance()->getActionName(); $module = sfContext::getInstance()->getModuleName(); } else { $module = strtok($uri, "/"); $action = strtok("/"); } if ($path === null) { $pathCU = new afConfigUtils($module); $path = $pathCU->getConfigFilePath($action . '.xml', true); if (strstr($path, "page")) { $page = true; } } $hash = sha1_file($path); $obj = afValidatorCachePeer::inCache($path); if (!$obj || $obj->getSignature() != $hash) { $doc = new XmlValidator($path, $security, false, false, $page ? $this->context->getModuleName() . "/" . $this->context->getActionName() : null); $doc->validateXmlDocument(); $this->document = $doc->getXmlDocument(); $this->validator = $doc; } else { $this->document = new DOMDocument(); $this->document->load($path); } parent::setNamespace($security); parent::setXmlDocument($this->document); parent::setXpath(); XmlBaseElementParser::clearRetVal(); }