Ejemplo n.º 1
0
/**
 * Checks if minifying a classes resources is explicitely forbidden
 * 
 * Uses NoMinify attribute to check that
 * @param string $classname Classname to check for
 * @return bool true or false
 */
function minify_forbidden($classname)
{
    if (is_string($classname) && strpos($classname, '.') !== false) {
        $classname = explode('.', $classname);
        $classname = $classname[0];
    }
    try {
        $ref = WdfReflector::GetInstance($classname);
        return count($ref->GetClassAttributes('NoMinify')) > 0;
    } catch (Exception $ex) {
        WdfException::Log("minify_forbidden({$classname})", $ex);
        return false;
    }
}
Ejemplo n.º 2
0
/**
 * Checks if minifying a classes resources is explicitely forbidden
 * 
 * Uses NoMinify attribute to check that
 * @param string $classname Classname to check for
 * @return bool true or false
 */
function minify_forbidden($classname)
{
    if (is_string($classname) && strpos($classname, '.') !== false) {
        $classname = explode('.', $classname);
        $classname = $classname[0];
    }
    try {
        $ref = WdfReflector::GetInstance($classname);
        return count($ref->GetClassAttributes('NoMinify')) > 0;
    } catch (Exception $ignored) {
        try {
            Template::Make($classname);
            // check if the name refers to an anonymous template
            return false;
        } catch (Exception $ex) {
            WdfException::Log("minify_forbidden({$classname})", $ex);
            return false;
        }
    }
}
Ejemplo n.º 3
0
/**
 * Returns the name of a given class constant.
 * 
 * Will check all constant values and return the first match.
 * @param string $class_name name of the class containing the constant
 * @param mixed $constant_value value of the constant to get
 * @param string $prefix Checked constants need to start with this prefix (useful if there are different constants with the same value)
 * @return string name of the found constant or NULL
 */
function name_from_constant($class_name, $constant_value, $prefix = false)
{
    $ref = WdfReflector::GetInstance($class_name);
    foreach ($ref->getConstants() as $name => $value) {
        if ($value == $constant_value && (!$prefix || starts_with($name, $prefix))) {
            return $name;
        }
    }
    return null;
}
Ejemplo n.º 4
0
 /**
  * Overrides <ReflectionClass::getMethod> to enable <WdfReflectionMethod> handling.
  * 
  * @param string $name Name of the method to get
  * @return WdfReflectionMethod A WdfReflectionMethod instance or false on error
  */
 public function getMethod($name)
 {
     try {
         $res = new WdfReflectionMethod($this->Classname, $name);
         return $res;
     } catch (Exception $e) {
         log_debug("Checking for extender method");
     }
     if ($this->Instance && $this->Instance instanceof Control) {
         foreach ($this->Instance->_extender as &$ex) {
             $ref = WdfReflector::GetInstance($ex);
             $res = $ref->getMethod($name);
             if ($res) {
                 return $res;
             }
         }
     }
     return false;
 }