示例#1
0
文件: klass.php 项目: bermi/akelos
 public function &_addOrUpdateClassDetails($class_name, &$File, &$Component, &$SourceAnalyzer, $class_details, $ExtendedClass = null)
 {
     $class_details = array('name' => $class_name, 'file_id' => $File->getId(), 'component_id' => $Component->getId(), 'description' => @$class_details['doc']);
     /*
     'doc' => trim($this->_latest_docs, "\n\t "),
     'doc_metadata' => $this->_latest_attributes,
     'class_name' => $this->_current_class,
     'extends' => trim($this->_current_class_extends),
     */
     $class_details = array_filter($class_details, 'strlen');
     if (!($Class = $this->findFirstBy('name', $class_name))) {
         $SourceAnalyzer->log('Adding class: ' . $class_name);
         if (!empty($ExtendedClass)) {
             $class_details = array('name' => $class_details['name']);
         }
         $Class = new Klass(array('init' => false));
         $Class->setConnection($this->getConnection());
         $Class->setAttributes($class_details);
         $Class->save();
         $SourceAnalyzer->log('Added class: ' . $class_name);
     } elseif (empty($ExtendedClass) && $File->getId() != $Class->get('file_id') || $Component->getId() != $Class->get('component_id')) {
         $SourceAnalyzer->log('Modifying class details: ' . $class_name);
         unset($class_details['name']);
         $Class->setAttributes($class_details);
         $Class->save();
     }
     return $Class;
 }
示例#2
0
文件: Base.php 项目: tany/php-note
<?php

namespace sns\filter;

\Klass::bind(__NAMESPACE__ . '\\Base', ['overviews' => function () {
    return ['sns/overview/fixed-header'];
}]);
trait Base
{
    use \sns\filter\Login;
}
示例#3
0
文件: Crud.php 项目: tany/php-note
<?php

namespace sns\filter;

\Klass::bind(__NAMESPACE__ . '\\Crud', ['views' => function () {
    return ['sns/view/crud'];
}]);
trait Crud
{
    protected abstract function model();
    public function index($request)
    {
        return $this->crudIndex($request);
    }
    public function see($request)
    {
        return $this->crudSee($request);
    }
    public function add($request)
    {
        return $this->crudAdd($request);
    }
    public function edit($request)
    {
        return $this->crudEdit($request);
    }
    public function drop($request)
    {
        return $this->crudDrop($request);
    }
    public function dropAll($request)
 public static function setAnotherEntityManager(EntityManager $entityManager)
 {
     self::$entityManager = $entityManager;
 }
示例#5
0
 public function addChild(Klass $child)
 {
     $this->_children[$child->getName()] = $child;
 }
示例#6
0
<?php

namespace mongo\feature;

\Klass::bind(__NAMESPACE__ . '\\Timestamp', ['beforeValidate' => function () {
    $date = new \DateTime();
    $this->created = $this->created ?? $date;
    $this->updated = $date;
}]);
trait Timestamp
{
}
示例#7
0
文件: Db.php 项目: tany/php-note
<?php

namespace sys\filter;

\Klass::bind(__NAMESPACE__ . '\\Db', ['views' => function () {
    return ['sys/view/db/main'];
}, 'overviews' => function () {
    return ['sns/overview/fixed-drawer'];
}]);
trait Db
{
}
// function Db__breadcrumbs() {
//     return function($request) {
//         //$this->overviews = ['sns/overview/fixed-header'];
//         $crumbs = [[$url = "/.sys/db/", 'Database']];
//         if ($db = $this->request->db) {
//             $crumbs[] = [$url = "{$url}{$db}/", $db];
//         }
//         if ($coll = $this->request->coll) {
//             $crumbs[] = [$url = "{$url}{$coll}/", $coll];
//         }
//         return $crumbs;
//     };
// }
示例#8
0
<?php

namespace mongo\feature;

\Klass::bind(__NAMESPACE__ . '\\SequenceId', ['schema' => function () {
    return ['_id' => ['type' => 'integer']];
}, 'beforeSave' => function () {
    if ($this->_id === null) {
        $this->_id = $this->nextId();
    }
}]);
trait SequenceId
{
    public function nextId()
    {
        if (isset($this->_id)) {
            return;
        }
        $command = ['findAndModify' => 'sequence', 'query' => ['_id' => "{$this->collectionName()}._id"], 'update' => ['$inc' => ['seq' => 1]], "upsert" => true, "new" => true];
        $cursor = $this->connect()->command($this->dbName(), $command);
        return current($cursor->toArray())->value->seq;
    }
}
示例#9
0
 protected static function classBinds($name)
 {
     return \Klass::binds(get_called_class(), $name);
 }
示例#10
0
 public function indexFile($file_path)
 {
     $file_path = trim($file_path, '/');
     $FileInstance = new File(array('init' => false));
     if ($this->db) {
         $FileInstance->setConnection($this->db);
     }
     $FileInstance->init();
     if ($UnIndexedPage = $FileInstance->findFirstBy('path AND has_been_analyzed', $file_path, false)) {
         $ComponentInstance = new Component(array('init' => false));
         if ($this->db) {
             $ComponentInstance->setConnection($this->db);
         }
         $ComponentInstance->init();
         $ClassInstance = new Klass(array('init' => false));
         if ($this->db) {
             $ClassInstance->setConnection($this->db);
         }
         $ClassInstance->init();
         $this->log('Analyzing file ' . $UnIndexedPage->path);
         $Component = $ComponentInstance->updateComponentDetails($UnIndexedPage, $this);
         $Classes = $ClassInstance->updateClassDetails($UnIndexedPage, $Component, $this);
         if (!empty($Classes)) {
             //AkDebug::debug($Classes);
         }
         $UnIndexedPage->set('has_been_analyzed', true);
         $UnIndexedPage->save();
     }
 }
示例#11
0
<?php

namespace sns\filter;

\Klass::bind(__NAMESPACE__ . '\\LoginRequired', ['before' => function ($request) {
    return $this->requireLogin();
}]);
trait LoginRequired
{
}