当前位置: 首页>>代码示例>>PHP>>正文


PHP Ak类代码示例

本文整理汇总了PHP中Ak的典型用法代码示例。如果您正苦于以下问题:PHP Ak类的具体用法?PHP Ak怎么用?PHP Ak使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Ak类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: log

 public function log($message, $type = '', $identifyer = '')
 {
     if (AK_LOG_EVENTS) {
         $Logger =& Ak::getLogger();
         $Logger->log($message, $type);
     }
 }
开发者ID:joeymetal,项目名称:v1,代码行数:7,代码来源:AkObject.php

示例2: Method

 function &updateClassDetails(&$File, &$Component, &$SourceAnalyzer)
 {
     Ak::import('method');
     $MethodInstance =& new Method();
     $parsed_details = $SourceAnalyzer->getParsedArray($File->body);
     $available_classes = empty($parsed_details['classes']) ? array() : array_keys($parsed_details['classes']);
     if (empty($available_classes)) {
         return $available_classes;
     }
     $Classes = array();
     foreach ($available_classes as $class_name) {
         $extends = !empty($parsed_details['classes'][$class_name]['extends']) ? $parsed_details['classes'][$class_name]['extends'] : false;
         if ($extends) {
             $SourceAnalyzer->log('Looking for parent class: ' . $extends);
             $ParentClass =& $this->_addOrUpdateClassDetails($extends, $File, $Component, $SourceAnalyzer, array(), true);
         }
         $Class =& $this->_addOrUpdateClassDetails($class_name, $File, $Component, $SourceAnalyzer, $parsed_details['classes'][$class_name]);
         if (!empty($ParentClass)) {
             $SourceAnalyzer->log('Setting ' . $extends . ' as the parent of ' . $class_name);
             $ParentClass->tree->addChild($Class);
             $ParentClass->save();
         }
         $Class->methods = array();
         if (!empty($parsed_details['classes'][$class_name]['methods'])) {
             foreach ($parsed_details['classes'][$class_name]['methods'] as $method_name => $method_details) {
                 $Class->methods[] =& $MethodInstance->updateMethodDetails($Class, $method_name, $method_details, $SourceAnalyzer);
             }
         }
         $Classes[] =& $Class;
     }
     return $Classes;
 }
开发者ID:joeymetal,项目名称:v1,代码行数:32,代码来源:akelos_class.php

示例3: makeClassExtensible

 function makeClassExtensible($class_name_to_extend)
 {
     list($checksum, $source) = $this->_getExtensionSourceAndChecksum($class_name_to_extend);
     $merge_path = AK_TMP_DIR . DS . '.lib';
     if ($source) {
         if (preg_match_all('/[ \\n\\t]*([a-z]+)[ \\n\\t]*extends[ \\n\\t]*(' . $class_name_to_extend . ')[ \\n\\t]*[ \\n\\t]*{/i', $source, $matches)) {
             $replacements = array();
             $extended_by = array();
             foreach ($matches[2] as $k => $class_to_extend) {
                 if (empty($last_method) && class_exists($class_to_extend)) {
                     $last_method = $class_to_extend;
                 }
                 if ($class_to_extend == $last_method || !empty($extended_by[$class_to_extend]) && in_array($last_method, $extended_by[$class_to_extend])) {
                     if (!class_exists($matches[1][$k])) {
                         $replacements[trim($matches[0][$k], "\n\t {")] = $matches[1][$k] . ' extends ' . $last_method;
                         $last_method = $matches[1][$k];
                         $extended_by[$class_to_extend][] = $last_method;
                     } else {
                         trigger_error(Ak::t('The class %class is already defined and can\'t be used for extending %parent_class', array('%class' => $matches[1][$k], '%parent_class' => $class_name_to_extend)), E_NOTICE);
                     }
                 }
             }
             $source = str_replace(array_keys($replacements), array_values($replacements), $source);
         }
         $source = "{$source}<?php class Extensible{$class_name_to_extend} extends {$last_method}{} ?>";
         if (md5($source) != @md5_file($merge_path . DS . 'Extensible' . $class_name_to_extend . '.php')) {
             AkFileSystem::file_put_contents($merge_path . DS . 'Extensible' . $class_name_to_extend . '.php', $source);
             AkFileSystem::file_put_contents($merge_path . DS . 'checksums' . DS . 'Extensible' . $class_name_to_extend, $checksum);
         }
     }
     include_once $merge_path . DS . 'Extensible' . $class_name_to_extend . '.php';
 }
开发者ID:bermi,项目名称:akelos,代码行数:32,代码来源:class_extender.php

示例4: test_should_fill_the_table_with_yaml_data

    public function test_should_fill_the_table_with_yaml_data()
    {
        $unit_tester = new AkUnitTest();
        $unit_tester->installAndIncludeModels(array('TheModel'=>'id,name'));
        $TheModel =& $unit_tester->TheModel;
        $TheModel->create(array('name'=>'eins'));
        $TheModel->create(array('name'=>'zwei'));
        $TheModel->create(array('name'=>'drei'));
        $TheModel->create(array('name'=>'vier'));
        $this->assertEqual($TheModel->count(),4);

        $this->assertTrue($AllRecords = $TheModel->find());
        $yaml = $TheModel->toYaml($AllRecords);
        $this->assertFalse(file_exists(AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.'the_models.yaml'));
        Ak::file_put_contents(AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.'the_models.yaml',$yaml);

        $unit_tester->installAndIncludeModels(array('TheModel'=>'id,name'));
        $this->assertFalse($TheModel->find());
        $this->assertEqual($TheModel->count(),0);

        $unit_tester->installAndIncludeModels(array('TheModel'=>'id,name'),array('populate'=>true));
        $this->assertEqual($TheModel->count(),4);
        unlink(AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.'the_models.yaml');

    }
开发者ID:joeymetal,项目名称:v1,代码行数:25,代码来源:AkUnitTest.php

示例5: generate

    function generate()
    {
        $this->_preloadPaths();

        $this->class_name = AkInflector::camelize($this->class_name);

        $files = array(
        'model'=>AkInflector::toModelFilename($this->class_name),
        'unit_test'=>AK_TEST_DIR.DS.'unit'.DS.'app'.DS.'models'.DS.$this->underscored_model_name.'.php',
        'model_fixture.tpl'=>AK_TEST_DIR.DS.'fixtures'.DS.$this->model_path,
        'installer_fixture.tpl'=>AK_TEST_DIR.DS.'fixtures'.DS.$this->installer_path
        );

        $this->_template_vars = (array)$this;

        foreach ($files as $template=>$file_path){
            $this->save($file_path, $this->render($template));
        }

        $installer_path = AK_APP_DIR.DS.'installers'.DS.$this->underscored_model_name.'_installer.php';
        if(!file_exists($installer_path)){
            $this->save($installer_path, $this->render('installer'));
        }

        $unit_test_runner = AK_TEST_DIR.DS.'unit.php';
        if(!file_exists($unit_test_runner)){
            Ak::file_put_contents($unit_test_runner, file_get_contents(AK_FRAMEWORK_DIR.DS.'test'.DS.'app.php'));
        }

    }
开发者ID:joeymetal,项目名称:v1,代码行数:30,代码来源:model_generator.php

示例6: _run_from_file

 function _run_from_file($file_name, $all_in_one_test = true)
 {
     $multiple_expected_php = $multiple_sintags = '';
     $tests = explode('===================================', file_get_contents(AK_TEST_DIR . DS . 'fixtures' . DS . 'data' . DS . $file_name));
     foreach ($tests as $test) {
         list($sintags, $php) = explode('-----------------------------------', $test);
         $sintags = trim($sintags);
         $expected_php = trim($php);
         if (empty($sintags)) {
             break;
         } else {
             $multiple_sintags .= $sintags;
             $multiple_expected_php .= $expected_php;
         }
         $AkSintags =& new AkSintagsParser();
         $php = $AkSintags->parse($sintags);
         if ($php != $expected_php) {
             Ak::trace("GENERATED: \n" . $php);
             Ak::trace("EXPECTED: \n" . $expected_php);
             Ak::trace("SINTAGS: \n" . $sintags);
         }
         $this->assertEqual($php, $expected_php);
     }
     if ($all_in_one_test) {
         $AkSintags =& new AkSintagsParser();
         $php = $AkSintags->parse($multiple_sintags);
         if ($php != $multiple_expected_php) {
             Ak::trace("GENERATED: \n" . $php);
             Ak::trace("EXPECTED: \n" . $expected_php);
             Ak::trace("SINTAGS: \n" . $sintags);
         }
         $this->assertEqual($php, $multiple_expected_php);
     }
 }
开发者ID:joeymetal,项目名称:v1,代码行数:34,代码来源:AkSintags.php

示例7: test_should_establish_multiple_connections

    function test_should_establish_multiple_connections()
    {
        if(AK_PHP5){
            $db_settings = Ak::convert('yaml', 'array', AK_CONFIG_DIR.DS.'database.yml');
            $db_settings['sqlite_databases'] = array(
                    'database_file' => AK_TMP_DIR.DS.'testing_sqlite_database.sqlite',
                    'type' => 'sqlite'
                    );
            file_put_contents(AK_CONFIG_DIR.DS.'database.yml', Ak::convert('array', 'yaml', $db_settings));
        
       
            $this->installAndIncludeModels(array('TestOtherConnection'));

            Ak::import('test_other_connection');
            $OtherConnection = new TestOtherConnection(array('name'=>'Delia'));
            $this->assertTrue($OtherConnection->save());
        
        
            $this->installAndIncludeModels(array('DummyModel'=>'id,name'));
            $Dummy = new DummyModel();
        
            $this->assertNotEqual($Dummy->getConnection(), $OtherConnection->getConnection());
        
            unset($db_settings['sqlite_databases']);
            file_put_contents(AK_CONFIG_DIR.DS.'database.yml', Ak::convert('array', 'yaml', $db_settings));
        }
    }
开发者ID:joeymetal,项目名称:v1,代码行数:27,代码来源:_AkActiveRecord_connection_handling.php

示例8: test_should_update_plugin

 function test_should_update_plugin()
 {
     Ak::directory_delete(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib');
     $this->assertFalse(file_exists(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib'.DS.'ActsAsVersioned.php'));
     $this->PluginManager->updatePlugin('acts_as_versioned');
     $this->assertTrue(file_exists(AK_PLUGINS_DIR.DS.'acts_as_versioned'.DS.'lib'.DS.'ActsAsVersioned.php'));
 }
开发者ID:joeymetal,项目名称:v1,代码行数:7,代码来源:AkPluginManager.php

示例9: saveReport

 function saveReport()
 {
     if ($this->report == '') {
         $this->renderReport();
     }
     Ak::file_put_contents('profiler_results.txt', $this->report);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:7,代码来源:AkProfiler.php

示例10: _getModelAttributesForViews

 private function _getModelAttributesForViews()
 {
     $attributes = array();
     $ModelInstance = Ak::get($this->class_name);
     if ($ModelInstance instanceof $this->class_name) {
         $table_name = $ModelInstance->getTableName();
         if (!empty($table_name)) {
             $attributes = $ModelInstance->getContentColumns();
             unset($attributes['updated_at'], $attributes['updated_on'], $attributes['created_at'], $attributes['created_on']);
         }
         $internationalized_columns = $ModelInstance->getInternationalizedColumns();
         foreach ($internationalized_columns as $column_name => $languages) {
             foreach ($languages as $lang) {
                 $attributes[$column_name] = $attributes[$lang . '_' . $column_name];
                 $attributes[$column_name]['name'] = $column_name;
                 unset($attributes[$lang . '_' . $column_name]);
             }
         }
     }
     $helper_methods = array('string' => 'text_field', 'text' => 'text_area', 'date' => 'text_field', 'datetime' => 'text_field');
     foreach ($attributes as $k => $v) {
         $attributes[$k]['type'] = $helper_methods[$attributes[$k]['type']];
     }
     return $attributes;
 }
开发者ID:bermi,项目名称:akelos,代码行数:25,代码来源:scaffold_controller_generator.php

示例11: index

 public function index()
 {
     $this->base_dir = AK_BASE_DIR;
     $this->akelos_dir = AK_FRAMEWORK_DIR;
     $this->tasks_dir = AK_TASKS_DIR;
     $this->has_configuration = file_exists(AkConfig::getDir('config') . DS . 'config.php');
     $this->has_routes = file_exists(AkConfig::getDir('config') . DS . 'routes.php');
     $this->has_database = file_exists(AkConfig::getDir('config') . DS . 'database.yml');
     $this->using_root_path = $this->Request->getPath() == '/';
     $this->new_install = !$this->has_configuration || !$this->has_routes || $this->using_root_path;
     $this->environment = AK_ENVIRONMENT;
     $this->memcached_on = AkMemcache::isServerUp();
     $this->constants = AkDebug::get_constants();
     $this->langs = Ak::langs();
     $this->database_settings = Ak::getSettings('database', false);
     $this->server_user = trim(AK_WIN ? `ECHO %USERNAME%` : `whoami`);
     $this->local_ips = AkConfig::getOption('local_ips', array('localhost', '127.0.0.1', '::1'));
     $paths = array(AK_APP_DIR . DS . 'locales');
     $this->invalid_permissions = array();
     foreach ($paths as $path) {
         if (is_dir($path) && !@file_put_contents($path . DS . '__test_file')) {
             $this->invalid_permissions[] = $path;
         } else {
             @unlink($path . DS . '__test_file');
         }
     }
 }
开发者ID:bermi,项目名称:akelos,代码行数:27,代码来源:akelos_dashboard_controller.php

示例12: generate

    function generate()
    {
        $this->_preloadPaths();

        $this->class_name = AkInflector::camelize($this->class_name);

        $files = array(
        'mailer'=>AkInflector::toModelFilename($this->class_name),
        'unit_test'=>AK_TEST_DIR.DS.'unit'.DS.'app'.DS.'models'.DS.$this->underscored_class_name.'.php'
        );

        foreach ($files as $template=>$file_path){
            $this->save($file_path, $this->render($template));
        }

        $mailer_views_folder = AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name);
        @Ak::make_dir($mailer_views_folder);

        foreach ($this->actions as $action){
            $this->assignVarToTemplate('action', $action);
            $path = $mailer_views_folder.DS.$action.'.tpl';
            $this->assignVarToTemplate('path', $path);
            $this->save($path, $this->render('view'));
        }
    }
开发者ID:joeymetal,项目名称:v1,代码行数:25,代码来源:mailer_generator.php

示例13: setImage

 public function setImage($image_path)
 {
     $this->Image = new AkImage($image_path);
     $this->Image->transform('resize', array('size' => '24x24'));
     $this->_tmp_file = AK_TMP_DIR . DS . '__AkImageColorScheme_' . Ak::randomString(32) . '.jpg';
     $this->Image->save($this->_tmp_file);
 }
开发者ID:bermi,项目名称:akelos,代码行数:7,代码来源:color_scheme.php

示例14: setup

 function setup()
 {
     $this->installAndIncludeModels(array('Post', 'Tag', 'Comment'));
     $Installer = new AkInstaller();
     @$Installer->dropTable('posts_tags');
     @Ak::file_delete(AK_MODELS_DIR.DS.'post_tag.php');
 }
开发者ID:joeymetal,项目名称:v1,代码行数:7,代码来源:_AkActiveRecord_finders.php

示例15: test_start

 public function test_start()
 {
     $this->installAndIncludeModels(array(
     'Category'=>'id, parent_id, description, department string(25)'
     ));
     Ak::import('DependentCategory');
 }
开发者ID:joeymetal,项目名称:v1,代码行数:7,代码来源:AkActsAsTree.php


注:本文中的Ak类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。