public function __call($function, $args) { $re = '/(' . join('|', array_keys(array_map('preg_quote', $this->_queryTypes))) . ')(.+?)(?:By(.+))*$/'; if (preg_match($re, $function, $matches)) { $queryType = $matches[1]; if (isset($this->_queryTypes[$queryType])) { $temp = str_split($matches[2]); $temp[0] = strtolower($temp[0]); $method_names = array('_' . $queryType . $matches[2] . 'Query', '_' . join($temp) . 'Query'); $queryMethod = $this->_queryTypes[$queryType]; if (isset($matches[3])) { array_unshift($method_names, '_' . $queryType . $matches[2] . 'ByQuery'); if (Zend_Version::compareVersion('1.7.9') < 0) { $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $field = strtolower($filter->filter($matches[3])); } else { $field = strtolower(Zend_Filter::filterStatic($matches[3], 'Word_CamelCaseToUnderscore')); } array_unshift($args, $field); } foreach ($method_names as $method) { if (method_exists($this, $method)) { $sql = call_user_func_array(array($this, $method), $args); return $this->{$queryMethod}($sql); break; } } die("Cannot find proper query method for function <b>" . $function . "</b> of class " . get_class($this)); } } de('Table.php: ', $function, $args); return parent::__call($function, $args); }
public function testFilterSeparatesCamelCasedWordsWithUnderscores() { $string = 'CamelCasedWords'; $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $filtered = $filter->filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Camel_Cased_Words', $filtered); }
public static function convert($array) { $filter = new \Zend_Filter_Word_CamelCaseToUnderscore(); $result = array(); foreach ($array as $key => $value) { $result[strtolower($filter->filter($key))] = $value; } return $result; }
public function getContents($language) { if (isset($this->_contentsCache)) { return $this->_contentsCache; } if (!$this->_features) { return null; } $outputFile = getcwd() . '/temp/modernizr-' . implode('-', $this->_features); if (file_exists("{$outputFile}.buildtime") && time() - file_get_contents("{$outputFile}.buildtime") < 24 * 60 * 60) { $ret = file_get_contents($outputFile); $this->_contentsCache = $ret; return $ret; } $extensibility = array("addtest" => false, "prefixed" => false, "teststyles" => false, "testprops" => false, "testallprops" => false, "hasevents" => false, "prefixes" => false, "domprefixes" => false); $tests = array(); foreach ($this->_features as $f) { if (isset($extensibility[strtolower($f)])) { $extensibility[strtolower($f)] = true; } else { //add two versions of the test //requried to support core detects (eg. CssAnimations) and non-core detects (css_mediaqueries) $tests[] = strtolower($f); $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $tests[] = strtolower($filter->filter($f)); } } if (Kwf_Config::getValue('application.uniquePrefix')) { $extensibility["cssclassprefix"] = Kwf_Config::getValue('application.uniquePrefix') . '-'; } $config = array('modernizr' => array('dist' => array('devFile' => false, 'outputFile' => $outputFile, 'extra' => array("shiv" => false, "printshiv" => false, "load" => false, "mq" => true, "cssclasses" => true), 'extensibility' => $extensibility, 'uglify' => true, 'tests' => $tests, 'parseFiles' => false, 'matchCommunityTests' => false, 'customTests' => array()))); $gruntfile = " module.exports = function(grunt) {\n"; $gruntfile .= " grunt.initConfig("; $gruntfile .= json_encode($config); $gruntfile .= ");\n"; $gruntfile .= " grunt.loadNpmTasks(\"grunt-modernizr\");\n"; $gruntfile .= " grunt.registerTask('default', ['modernizr']);\n"; $gruntfile .= "};\n"; $cwd = getcwd(); chdir(dirname(dirname(dirname(dirname(__FILE__))))); file_put_contents('Gruntfile.js', $gruntfile); $cmd = $cwd . "/" . VENDOR_PATH . "/bin/node ./node_modules/grunt-cli/bin/grunt 2>&1"; exec($cmd, $out, $retVar); unlink('Gruntfile.js'); if (file_exists($outputFile)) { $ret = file_get_contents($outputFile); } chdir($cwd); if ($retVar) { throw new Kwf_Exception("Grunt failed: " . implode("\n", $out)); } file_put_contents("{$outputFile}.buildtime", time()); $this->_contentsCache = $ret; return $ret; }
public function __call($method, $args) { $prefix = strtolower(substr($method, 0, 3)); if ($prefix == "get") { $len = strlen($method); $key = substr($method, 3, $len); $filter = new \Zend_Filter_Word_CamelCaseToUnderscore(); $key = strtolower($filter->filter($key)); return $this->getParam($key); } throw new Exception("Method requested {$method} does not exist."); }
public static function __callStatic($method, array $args) { $object = static::getInstance(); $command = substr($method, 0, 3); $const = substr($method, 3); if ('get' !== $command) { throw new BadMethodCallException("Método inexistente. {$command}{$const}"); } $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $const = strtoupper($filter->filter($const)); if (!isset($object->{$const})) { throw new BadMethodCallException("Método inexistente. '{$const}'"); } return $object->get($const); }
public static function __callStatic($method, array $args) { $object = static::getInstance(); $command = substr($method, 0, 3); $const = substr($method, 3); if ('get' !== $command) { throw new BadMethodCallException(sprintf('Método "%s::%s()" não começa com "get".', get_class($object), $method)); } $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $const = strtoupper($filter->filter($const)); if (!isset($object->{$const})) { throw new BadMethodCallException(sprintf('Constante de sicae.configuracao "%s" não registrada.', $const)); } return $object->get($const); }
/** * Calls a method of a decorator instance. * @param $method * @param $arguments * @return unknown_type */ public function __call($method, $arguments) { // the suffix of $method is class name $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $tokens = $filter->filter($method); $tokens = explode('_', $tokens); $class = self::COMPONENT_NAMESPACE . $tokens[count($tokens) - 1]; $decorator = new $class(); if (count($arguments) == 1) { return $decorator->{$method}($arguments[0]); } elseif (count($arguments) == 2) { return $decorator->{$method}($arguments[0], $arguments[1]); } else { return $decorator->{$method}($arguments); } }
public function __call($method, $args) { $prefix = strtolower(substr($method, 0, 3)); if ($prefix == "set" || $prefix == "get") { $len = strlen($method); $key = substr($method, 3, $len); $filter = new \Zend_Filter_Word_CamelCaseToUnderscore(); $key = strtolower($filter->filter($key)); if ($prefix == "set") { return call_user_func(array($this, 'addData'), $key, $args[0]); } elseif ($prefix == "get") { return $this->getData($key); } } throw new \Exception("Method requested {$method} does not exist."); }
public function testFilterSeperatingNumbersToUnterscore() { $string = 'PaTitle'; $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $filtered = $filter->filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Pa_Title', $filtered); $string = 'Pa2Title'; $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $filtered = $filter->filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Pa2_Title', $filtered); $string = 'Pa2aTitle'; $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $filtered = $filter->filter($string); $this->assertNotEquals($string, $filtered); $this->assertEquals('Pa2a_Title', $filtered); }
/** * Get the property name as defined in the Storage * * @return string */ public function getFieldName() { if (null === $this->_fieldName) { $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $this->_fieldName = ltrim(strtolower($filter->filter($this->getPropertyName())), '_'); } return $this->_fieldName; }
/** * Preps the entity's data before saving it to the database. In this case, * property names are reverted back to lowercase and underscores, and any * properties that are not in the table are removed from the array * @param array $data * @return array */ protected function _prepData(array $data) { $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $preppedData = array(); // get the columns from the tables $tableColumns = $this->getDbTable()->info(Zend_Db_Table::COLS); foreach ($data as $key => $val) { $col = strtolower($filter->filter($key)); // this makes sure that only existing table properties get inserted // as well as any values that are null are unset if (in_array($col, $tableColumns)) { $preppedData[$col] = $val; } } return $preppedData; }
/** * Get the reference Storage uses * * @return string */ public function getStorageReference() { if (null === $this->_storageReference) { $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); $this->setStorageReference(strtolower($filter->filter($this->getEntityName()))); } return $this->_storageReference; }
public function cameltounder($str) { $a = new Zend_Filter_Word_CamelCaseToUnderscore(); return strtolower($a->filter($str)); }
/** * Metodo para tranformar as variaveis PHP em colunas do bd * id_usuario => idUsuario * * @param string $value */ protected function _camelToUnder($value) { $filter = new Zend_Filter_Word_CamelCaseToUnderscore(); return strtolower($filter->filter($value)); }