本文整理汇总了PHP中Solar_File类的典型用法代码示例。如果您正苦于以下问题:PHP Solar_File类的具体用法?PHP Solar_File怎么用?PHP Solar_File使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Solar_File类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _setup
/**
*
* Model-specific setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_belongsTo('node');
}
示例2: _exec
/**
*
* Write out a series of dirs and symlinks for a new Vendor source.
*
* @param string $vendor The Vendor name.
*
* @return void
*
*/
protected function _exec($vendor = null)
{
// we need a vendor name, at least
if (!$vendor) {
throw $this->_exception('ERR_NO_VENDOR_NAME');
}
$this->_outln("Removing links for vendor '{$vendor}' ...");
// build "foo-bar" and "FooBar" versions of the vendor name.
$this->_inflect = Solar_Registry::get('inflect');
$this->_dashes = $this->_inflect->camelToDashes($vendor);
$this->_studly = $this->_inflect->dashesToStudly($this->_dashes);
// the base system dir
$system = Solar::$system;
// the links to remove (reverse order from make-vendor)
$links = array("script/{$this->_dashes}", "include/Mock/{$this->_studly}", "include/Test/{$this->_studly}", "include/{$this->_studly}");
// remove the links
foreach ($links as $link) {
$this->_out(" Removing '{$link}' ... ");
$path = "{$system}/{$link}";
if (Solar_File::exists($path)) {
unlink($path);
$this->_outln("done.");
} else {
$this->_outln("missing.");
}
}
// done!
$this->_outln("... done.");
// reminders
$this->_outln("Remember to remove '{$this->_studly}_App' from the " . "['Solar_Controller_Front']['classes'] element " . "in your config file.");
$this->_outln("Remember to remove '{$this->_studly}_Model' from the " . "['Solar_Sql_Model_Catalog']['classes'] element " . "in your config file.");
// need to write a recursive-remove method for Solar_Dir that will
// delete only the symlinked files (not the real files)
$this->_outln("You will need to remove the " . "'docroot/public/{$this->_studly}' directory yourself, as it " . "may contain copies of public assets (not links).");
}
示例3: _setup
/**
*
* Model-specific setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = $this->_config['prefix'] . Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_hasMany('moduleinfo', array('foreign_class' => 'Foresmo_Model_ModuleInfo', 'foreign_key' => 'module_id'));
}
示例4: _setup
/**
*
* Model-specific setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = $this->_config['prefix'] . Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_belongsTo('comments', array('foreign_class' => 'Foresmo_Model_Comments'));
}
示例5: fetch
/**
*
* Fetches the roles for a username.
*
* @param string $handle User handle to get roles for.
*
* @return array An array of discovered roles.
*
*/
public function fetch($handle)
{
// force the full, real path to the file
$file = realpath($this->_config['file']);
// does the file exist?
if (!Solar_File::exists($file)) {
throw $this->_exception('ERR_FILE_NOT_READABLE', array('file' => $file));
}
// load the file as an array of lines
$lines = file($file);
// the discovered roles
$roles = array();
// loop through each line, find the group, then see if the user
// is on the line anywhere
foreach ($lines as $line) {
// eliminate all spaces, which cause mismatches when we get to
// in_array() later
$line = preg_replace("/\\s/", '', $line);
// break apart at first ':'
$pos = strpos($line, ':');
// the group name is the part before the ':'
$group = substr($line, 0, $pos);
// the list of user handles comes after
$tmp = substr($line, $pos + 1);
$list = explode(',', $tmp);
// is the user part of the group?
if (in_array($handle, $list)) {
$roles[] = $group;
}
}
// done!
return $roles;
}
示例6: autoload
/**
*
* Loads a class or interface file from the include_path.
*
* Thanks to Robert Gonzalez for the report leading to this method.
*
* @param string $name A Solar (or other) class or interface name.
*
* @return void
*
* @todo Add localization for errors
*
*/
public static function autoload($name)
{
// did we ask for a non-blank name?
if (trim($name) == '') {
throw Solar::exception('Solar_Class', 'ERR_AUTOLOAD_EMPTY', 'No class or interface named for loading.', array('name' => $name));
}
// pre-empt further searching for the named class or interface.
// do not use autoload, because this method is registered with
// spl_autoload already.
$exists = class_exists($name, false) || interface_exists($name, false);
if ($exists) {
return;
}
// convert the class name to a file path.
$file = str_replace('_', DIRECTORY_SEPARATOR, $name) . '.php';
// include the file and check for failure. we use Solar_File::load()
// instead of require() so we can see the exception backtrace.
Solar_File::load($file);
// if the class or interface was not in the file, we have a problem.
// do not use autoload, because this method is registered with
// spl_autoload already.
$exists = class_exists($name, false) || interface_exists($name, false);
if (!$exists) {
throw Solar::exception('Solar_Class', 'ERR_AUTOLOAD_FAILED', 'Class or interface does not exist in loaded file', array('name' => $name, 'file' => $file));
}
}
示例7: _setup
/**
*
* Model-specific setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_index = Solar_File::load($dir . 'index_info.php');
/**
* Special columns
*/
$this->_serialize_cols[] = 'prefs';
$this->_calculate_cols[] = 'tags_as_string';
/**
* Filters
*/
// make sure the name is unique for its area and model
$where = array('inherit = :inherit', 'area_id = :area_id');
$this->_addFilter('name', 'validateUnique', $where);
// other filters
$this->_addFilter('email', 'validateEmail');
$this->_addFilter('uri', 'validateUri');
$this->_addFilter('editor_ipaddr', 'validateIpv4');
$this->_addFilter('locale', 'validateLocaleCode');
$this->_addFilter('mime', 'validateMimeType');
$this->_addFilter('tags_as_string', 'validateSepWords');
/**
* Relationships.
*/
$this->_belongsTo('area');
$this->_hasMany('taggings');
$this->_hasMany('tags', array('through' => 'taggings'));
}
示例8: _setup
/**
*
* Model-specific setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = $this->_config['prefix'] . Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_hasMany('userinfo', array('foreign_class' => 'Foresmo_Model_UserInfo', 'foreign_key' => 'user_id'));
$this->_hasOne('groups', array('foreign_class' => 'Foresmo_Model_Groups', 'native_col' => 'group_id', 'foreign_col' => 'id'));
}
示例9: _setup
/**
*
* Model-specific setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = $this->_config['prefix'] . Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_hasMany('posts_tags', array('foreign_class' => 'Foresmo_Model_PostsTags', 'foreign_key' => 'tag_id'));
$this->_hasMany('posts', array('foreign_class' => 'Foresmo_Model_Posts', 'through' => 'posts_tags', 'through_key' => 'post_id', 'through_native_col' => 'tag_id', 'through_foreign_col' => 'post_id', 'conditions' => array('status = ?' => array(1))));
}
示例10: setup
public function setup()
{
// easier to do this here than as a property, since we use functions.
$this->_config = array('adapters' => array(array('adapter' => 'Solar_Log_Adapter_File', 'events' => 'debug', 'file' => Solar_File::tmp('test_solar_log_adapter_multi.debug.log'), 'format' => '%e %m'), array('adapter' => 'Solar_Log_Adapter_File', 'events' => 'info, notice', 'file' => Solar_File::tmp('test_solar_log_adapter_multi.other.log'), 'format' => '%e %m')));
parent::setup();
@unlink($this->_config['adapters'][0]['file']);
@unlink($this->_config['adapters'][1]['file']);
}
示例11: _setup
/**
*
* Model setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_model_name = 'users';
$this->_index = array('created', 'updated', 'handle' => 'unique');
}
示例12: _setup
/**
*
* Model-specific setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = $this->_config['prefix'] . Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_belongsTo('tags', array('foreign_key' => 'id'));
$this->_belongsTo('posts', array('foreign_key' => 'id'));
}
示例13: _setup
/**
*
* Model-specific setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = $this->_config['prefix'] . Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_hasMany('comments');
$this->_hasMany('permissions', array('through' => 'groupspermissions'));
}
示例14: testCallbacks_instanceMethod
public function testCallbacks_instanceMethod()
{
$file = Solar_Class::dir('Mock_Solar') . 'callbacks-instance-method.php';
Solar_File::load($file);
$instance = Solar::factory('Solar_Callbacks_Instance_Method');
Solar::callbacks(array(array($instance, 'callback')));
$this->assertTrue($GLOBALS['SOLAR_CALLBACKS_INSTANCE_METHOD']);
}
示例15: _setup
/**
*
* Model setup.
*
* @return void
*
*/
protected function _setup()
{
$dir = str_replace('_', DIRECTORY_SEPARATOR, __CLASS__) . DIRECTORY_SEPARATOR . 'Setup' . DIRECTORY_SEPARATOR;
$this->_table_name = Solar_File::load($dir . 'table_name.php');
$this->_table_cols = Solar_File::load($dir . 'table_cols.php');
$this->_addFilter('email', 'validateEmail');
$this->_addFilter('uri', 'validateUri');
$this->_index_info = array('created', 'updated', 'email' => 'unique', 'uri');
}