Exemple #1
0
/**
 * Get class header 
 * 
 * @param string $path Path
 *  
 * @return string
 * @see    ____func_see____
 * @since  1.0.18
 */
function macro_get_class_header($path)
{
    $class = macro_convert_path_to_class_name($path);
    $reflection = new \ReflectionClass($class);
    $header = $reflection->getDocComment();
    if (!$header) {
        $name = $reflection->getShortName();
        $header = <<<HEAD
/**
 * Abstract widget
 *
 * @see   ____class_see____
 * @since 1.0.0
 */
HEAD;
    }
    if (macro_is_entity($path)) {
        $header = preg_replace('/@Index\\s*\\(.+\\)/SsU', '', $header);
        $header = preg_replace('/@UniqueConstraint\\s*\\(.+\\)/SsU', '', $header);
        $header = preg_replace('/@MappedSuperclass/SsU', '', $header);
        $header = preg_replace('/@DiscriminatorMap\\s*\\(.+\\)/SsU', '', $header);
        $header = preg_replace('/@DiscriminatorColumn\\s*\\(.+\\)/SsU', '', $header);
        $header = preg_replace('/@InheritanceType\\s*\\(.+\\)/SsU', '', $header);
        $header = preg_replace('/@HasLifecycleCallbacks/SsU', '', $header);
        $header = preg_replace('/@Table\\s*\\(.+\\)/SsU', '', $header);
        $header = preg_replace('/@Entity\\s*\\(.+\\)/SsU', '', $header);
        $header = preg_replace('/@Entity/SsU', '', $header);
    }
    $header = preg_replace('/@ListChild\\s*\\(.+\\)/SsU', '', $header);
    $header = preg_replace('/( \\*\\s*.)+ \\*\\//SsU', ' */', $header);
    return $header;
}
Exemple #2
0
 * @see       ____file_see____
 * @since     1.0.18
 */
/**
 * Decorate class by file path
 */
require_once __DIR__ . '/core.php';
// get arguments
$path = macro_get_plain_argument(0);
$author = macro_get_plain_argument(1);
$module = macro_get_plain_argument(2);
// Check arguments
macro_check_file_path($path);
macro_check_module($author, $module);
// Assemble decorate class name
$decoratedClass = macro_convert_path_to_class_name($path);
// Assemble target class name
$parts = explode('\\', $decoratedClass);
array_shift($parts);
$parts = array_values($parts);
if (0 == count($parts)) {
    $parts = array('XLite');
} elseif ('Module' == $parts[0]) {
    $parts = array_slice($parts, 3);
}
$targetClass = 'XLite\\Module\\' . $author . '\\' . $module . '\\' . implode('\\', $parts);
// Assemble target file path
$targetPath = macro_convert_class_name_to_path($targetClass);
// Get file content
$decoratedClassFull = '\\' . $decoratedClass;
$className = array_pop($parts);