本文整理汇总了PHP中object::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP object::exists方法的具体用法?PHP object::exists怎么用?PHP object::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: read
/**
* Read the data for a particular session identifier from the
* SessionHandler backend.
*
* @param string $id The session identifier.
* @return string The session data.
*/
public function read($session_id)
{
if ($this->files->exists($path = $this->path . DS . $session_id)) {
return $this->files->get($path);
}
return '';
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$c = strtolower($this->argument('controller'));
$files = [];
$files[] = mkny_models_path($c) . '.php';
$files[] = mkny_model_config_path($c) . '.php';
$files[] = mkny_presenters_path($c) . 'Presenter.php';
$files[] = mkny_controllers_path($c) . 'Controller.php';
$files[] = mkny_requests_path($c) . 'Request.php';
$files[] = mkny_lang_path(\App::getLocale() . '/' . $c) . '.php';
$errors = [];
foreach ($files as $file) {
if (!$this->files->exists($file)) {
$errors[] = $file;
}
}
if (!$this->option('force') && count($errors)) {
$this->error("Nao foi possivel executar o delete-automatico!\nAlguns arquivos estao ausentes!");
} else {
if ($this->option('force') || $this->confirm("Deseja realmente remover os arquivos: \n'" . implode("',\n'", $files))) {
foreach ($files as $file) {
$this->files->delete($file);
}
$this->info('Deleted!');
}
}
}
示例3: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (is_null($this->argument('vendor')) or is_null($this->argument('name'))) {
$this->info('Moving tests for all local packages');
$composer = json_decode(file_get_contents('composer.json'), true);
foreach ($composer['autoload']['psr-4'] as $package => $path) {
if ($package !== 'App\\') {
$packages[] = [rtrim($package, '\\'), $path];
}
}
foreach ($packages as $package) {
$path = dirname(getcwd() . '/' . $package[1]) . '/tests';
if ($this->files->exists($path)) {
$this->info('Moving tests for the package: ' . $package[0]);
$this->files->copyDirectory($path, getcwd() . '/tests/packages/' . $package[0]);
} else {
$this->info('No tests found for: ' . $package[0]);
}
}
} else {
$vendor = $this->argument('vendor');
$name = $this->argument('name');
$path = getcwd() . '/packages/' . $vendor . '/' . $name . '/tests';
if ($this->files->exists($path)) {
$this->info('Moving tests for the package: ' . $vendor . '/' . $name);
$r = $this->files->copyDirectory($path, getcwd() . '/tests/packages/' . $vendor . '/' . $name);
} else {
$this->info('No tests found for: ' . $vendor . '/' . $name);
}
}
$this->info('Done!');
}
示例4: exists
/**
* Determines if file or folder identified in path exists
*
* @param string $path
*
* @return bool
* @since 1.0
* @throws RuntimeException
*/
public function exists($path)
{
try {
return $this->adapter->exists($path);
} catch (Exception $e) {
throw new RuntimeException('Filesystem: Exists Exception ' . $e->getMessage());
}
}
示例5: auth
/**
* prompts the user to login if it exists in the database, else it prompts for registration
*/
public function auth()
{
if (!$this->user->isLoggedIn()) {
if ($this->user->exists()) {
// load the login template
$view = 'admin/login';
// users exist, set up the login verification process
// if theres input
if (Input::exists()) {
// get input values
$username = Input::get('username');
$password = Input::get('password');
// check if a unique token is set
if (Token::check(Input::get('token'))) {
// validate the form
$this->validator->validate(['username' => [$username, 'required'], 'password' => [$password, 'required']]);
if ($this->validator->passes()) {
// log the user in
if ($this->user->login($username, $password)) {
header('Location: /admin/index');
}
}
}
}
// delete the flash message that occurs after registering an account
if (Session::exists('success')) {
$flash = Session::flash('success');
}
} else {
// load the registration template
$view = 'admin/register';
// no users exist, set up the registration process
// if theres input
if (Input::exists()) {
// get input values
$username = Input::get('username');
$password = Input::get('password');
$password_confirmation = Input::get('password_confirmation');
// check if a unique token is set
if (Token::check(Input::get('token'))) {
// validate the form
$this->validator->validate(['username' => [$username, 'required|alnumDash|min(3)|max(25)'], 'password' => [$password, 'required|min(8)'], 'password_confirmation' => [$password_confirmation, 'required|matches(password)']]);
if ($this->validator->passes()) {
// validation passed, insert a new user to the database
$this->user->create($username, Hash::hashPassword($password));
Session::flash('success', 'Your account has been successfully created.');
header('Location: /admin/auth');
}
}
}
}
// render the right view
$this->view($view, ['flash_message' => isset($flash) ? $flash : '', 'validation_errors' => $this->validator->errors(), 'csrf_token' => Token::generate(), 'user_error' => $this->user->auth_error_message]);
} else {
// the user is already logged in
header('Location: /admin/index');
}
}
示例6: instance
/**
* 从注册器读取实例, 没有则注册
*
* @param string $name
*/
public function instance($name)
{
if ($this->registry->exists($name)) {
return $this->registry->get($name);
}
return $this->registry->instance($name);
}
示例7: login_check
/**
* Verifica se o usuário está logado
* @return boolean Status da autenticação
*/
public function login_check()
{
if ($this->storage->exists('user_id') && $this->storage->exists('username') && $this->storage->exists('login_string')) {
$login_string = hash('sha512', $this->storage->get('username') . $this->request->server('REMOTE_ADDR') . $this->request->server('HTTP_USER_AGENT'));
return $login_string == $this->storage->get('login_string') ? true : false;
}
}
示例8: testNotExistsNoMapValidExtensions
/**
* @covers Molajo\Resource\Proxy::setNamespace
* @covers Molajo\Resource\Proxy::exists
* @covers Molajo\Resource\Proxy::get
* @covers Molajo\Resource\Proxy::getCollection
* @covers Molajo\Resource\Proxy\Scheme::__construct
* @covers Molajo\Resource\Proxy\Scheme::setScheme
* @covers Molajo\Resource\Proxy\Scheme::getScheme
* @covers Molajo\Resource\Proxy\Scheme::setAdapterNamespaces
* @covers Molajo\Resource\Proxy\Scheme::saveNamespaceArray
* @covers Molajo\Resource\Proxy\Scheme::locateScheme
* @covers Molajo\Resource\Proxy\Scheme::getUriScheme
* @covers Molajo\Resource\Proxy\Scheme::removeUriScheme
* @covers Molajo\Resource\Adapter\NamespaceHandler::setNamespace
* @covers Molajo\Resource\Adapter\NamespaceHandler::exists
* @covers Molajo\Resource\Adapter\NamespaceHandler::get
* @covers Molajo\Resource\Adapter\NamespaceHandler::getCollection
* @covers Molajo\Resource\Adapter\NamespaceHandler::locateResourceNamespace
* @covers Molajo\Resource\Adapter\SetNamespace::setNamespaceExists
* @covers Molajo\Resource\Adapter\SetNamespace::appendNamespace
* @covers Molajo\Resource\Adapter\SetNamespace::prependNamespace
* @covers Molajo\Resource\Adapter\HandleNamespacePrefixes::searchNamespacePrefixes
* @covers Molajo\Resource\Adapter\HandleNamespacePrefixes::searchNamespacePrefix
* @covers Molajo\Resource\Adapter\HandleNamespacePrefixes::searchNamespacePrefixDirectory
* @covers Molajo\Resource\Adapter\HandleNamespacePrefixes::searchNamespacePrepareNamespacePath
* @covers Molajo\Resource\Adapter\HandleNamespacePrefixes::searchNamespaceFilename
* @covers Molajo\Resource\Adapter\HandleNamespacePrefixes::searchNamespacePrefixFileExtensions
* @covers Molajo\Resource\Adapter\HandleResourceMap::searchResourceMap
* @covers Molajo\Resource\Adapter\HandleResourceMap::searchResourceMapInstance
* @covers Molajo\Resource\Adapter\HandleResourceMap::setResourceMapPaths
* @covers Molajo\Resource\Adapter\HandleResourceMap::searchResourceMapPaths
* @covers Molajo\Resource\Adapter\HandleResourceMap::searchResourceMapFileExtensions
* @covers Molajo\Resource\Adapter\Base::__construct
* @covers Molajo\Resource\Adapter\Base::initialiseCacheVariables
* @covers Molajo\Resource\Adapter\Base::setScheme
* @covers Molajo\Resource\Adapter\Base::setResourceNamespace
* @covers Molajo\Resource\Adapter\Cache::getConfigurationCache
* @covers Molajo\Resource\Adapter\Cache::setConfigurationCache
* @covers Molajo\Resource\Adapter\Cache::deleteConfigurationCache
* @covers Molajo\Resource\Adapter\Cache::useConfigurationCache
* @covers Molajo\Resource\Adapter\Cache::getCache
* @covers Molajo\Resource\Adapter\Cache::setCache
* @covers Molajo\Resource\Adapter\Cache::deleteCache
* @covers Molajo\Resource\Adapter\Cache::clearCache
*
* @return $this
* @since 1.0.0
*/
public function testNotExistsNoMapValidExtensions()
{
$this->setAdapterValidExtensions();
$this->setNs();
$this->assertEquals(false, $this->proxy_instance->exists('xyz:\\\\molajo\\b\\bananarana'));
return $this;
}
示例9: read
/**
* Read a key from the cache
*
* @param string $key Identifier for the data
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
* @access public
*/
function read($key)
{
if ($this->__setKey($key) === false || !$this->__init || !$this->__File->exists()) {
return false;
}
if ($this->settings['lock']) {
$this->__File->lock = true;
}
$time = time();
$cachetime = intval($this->__File->read(11));
if ($cachetime !== false && ($cachetime < $time || $time + $this->settings['duration'] < $cachetime)) {
$this->__File->close();
$this->__File->delete();
return false;
}
$data = $this->__File->read(true);
if ($data !== '' && !empty($this->settings['serialize'])) {
if ($this->settings['isWindows']) {
$data = str_replace('\\\\\\\\', '\\', $data);
}
$data = unserialize((string) $data);
}
$this->__File->close();
return $data;
}
示例10: exists
/**
* key是否存在,存在返回ture
*
* @access public
*
* @param string $key KEY名称
*
* @return boolean
*/
public function exists($key)
{
//参数分析
if (!$key) {
return false;
}
return $this->_Redis->exists($key);
}
示例11: _state
/**
* Handler for extracting the state of resource instances.
*
* @see Lead\Resource\Controller::state()
*
* @param object $resource A resource instance.
* @return array
*/
protected function _state($resource)
{
$handlers = ['Chaos\\Collection' => function ($resource) {
$exists = $resource->invoke('exists');
$validates = $resource->invoke('validates');
return ['exists' => $resource->exists(), 'valid' => $resource->validates()];
}, 'Chaos\\Model' => function ($resource) {
return ['exists' => $resource->exists(), 'valid' => $resource->validates()];
}];
if ($resource) {
foreach ($handlers as $class => $handler) {
if ($resource instanceof $class) {
return $handler($resource);
}
}
}
return [];
}
示例12: load
/**
* Load a configuration file
*
* @param $dotOrFilePath Absolute path to config file, or dot-notation path from basepath (default: app/config) (existing, or to-be)
* @return $this
*/
public function load($dotOrFilePath)
{
$this->setFilename($dotOrFilePath);
// check if file already exists
if ($this->filesystem->exists($this->filename)) {
// require file and check that it returns an array
try {
if (is_array($config = $this->filesystem->getRequire($this->filename))) {
$this->configValues = $config;
} else {
throw new \Exception('Existing configuration file could not be loaded (not valid array).');
}
} catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
}
return $this;
}
示例13: set
/**
* Sets data to a specified offset and wraps all data array in its appropriate object type.
*
* @param mixed $data An array or an entity instance to set.
* @param mixed $offset The offset. If offset is `null` data is simply appended to the set.
* @param array $options Any additional options to pass to the `Entity`'s constructor.
* @return object Returns the inserted instance.
*/
public function set($offset = null, $data = [])
{
$name = $this->_through;
$parent = $this->_parent;
$relThrough = $parent->schema()->relation($name);
$through = $relThrough->to();
$item = $through::create($this->_parent->exists() ? $relThrough->match($this->_parent) : []);
$item->{$this->_using} = $data;
return $this->_parent->{$name}->set($offset, $item);
}
示例14: offsetSet
/**
* Adds the specified object to the `Collection` instance, and assigns associated metadata to
* the added object.
*
* @param string $offset The offset to assign the value to.
* @param mixed $data The entity object to add.
* @return mixed Returns the set `Entity` object.
*/
public function offsetSet($offset, $data)
{
$name = $this->_through;
$parent = $this->parent();
$relThrough = $parent::relation($name);
$through = $relThrough->to();
$item = $through::create($this->_parent->exists() ? $relThrough->match($this->_parent) : []);
$item->{$this->_using} = $data;
return $offset !== null ? $this->_parent->{$name}[$offset] = $item : ($this->_parent->{$name}[] = $item);
}
示例15: testDelete
public function testDelete()
{
global $g_ado_db;
$this->articleType->delete();
$this->assertFalse($this->articleType->exists());
$tableName = $g_ado_db->GetOne("SHOW TABLES LIKE '%X".$this->testTypeName."'");
$this->assertEquals('', $tableName);
$count = $g_ado_db->GetOne("SELECT COUNT(*) FROM ArticleTypeMetadata WHERE type_name = '".$this->testTypeName."'");
$this->assertEquals(0, $count);
}