本文整理汇总了PHP中D类的典型用法代码示例。如果您正苦于以下问题:PHP D类的具体用法?PHP D怎么用?PHP D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSiblings
public function testSiblings()
{
$node = new Node();
$node->appendChild($a = new A());
$b = new B($node);
$node->prependChild($c = new C());
$node->appendChild($d = new D());
$a->remove();
$this->assertSame(null, $c->getPreviousSibling());
$this->assertSame($b, $c->getNextSibling());
$this->assertSame(null, $d->getNextSibling());
$this->assertSame($b, $d->getPreviousSibling());
$this->assertSame($c, $b->getPreviousSibling());
$this->assertSame($d, $b->getNextSibling());
}
示例2: getValue
public static function getValue($value, $settings, $model)
{
// Check if the src is set and the converted values are not - this means we need to check for
// the progress file and possibly update the database
if (is_array($value) && isset($value['src']) && strlen($value['src']) > 0 && (!isset($value['converted']) || empty($value['converted']))) {
// See if the progress file exists
$path = DOCROOT . $value['src'];
if (file_exists($path . '.progress')) {
$value['progress'] = json_decode(file_get_contents($path . '.progress'));
} else {
// It doesn't exist - populate the field
if (isset($value['progress'])) {
unset($value['progress']);
}
$path_info = pathinfo($value['src']);
$value['poster'] = $path_info['dirname'] . '/' . $path_info['basename'] . '.jpg';
$value['converted'] = array('mp4' => $path_info['dirname'] . '/converted/' . $path_info['filename'] . '.mp4', 'webm' => $path_info['dirname'] . '/converted/' . $path_info['filename'] . '.webm');
//$class = \CMF::getClass($model);
$field_name = $settings['mapping']['fieldName'];
$model->set($field_name, $value);
\D::manager()->persist($model);
\D::manager()->flush();
}
}
return $value;
}
示例3: enableListener
public static function enableListener()
{
if (empty(static::$listener)) {
return;
}
\D::manager()->getEventManager()->addEventSubscriber(static::$listener);
}
示例4: main
function main()
{
$c = new C();
B::test($c);
C::test($c);
D::test($c);
}
示例5: main
function main()
{
$c = new C();
$d = new D();
$c->foo();
$d->foo();
echo "**************\n";
$c->bar();
$d->bar();
echo "**************\n";
C::foo();
D::bar();
echo "**************\n";
$d->yar();
D::yar();
}
示例6: __callStatic
public static function __callStatic($name, $args)
{
if (!self::$instance) {
self::$instance = new D\ump();
}
return call_user_func_array([self::$instance, $name], $args);
}
示例7: removeOldKeys
/**
* Purge all expired API keys from the database
*/
public function removeOldKeys()
{
$keys = \CMF\Model\User\Apikey::select('item')->andWhere('item.expires_at < :now')->setParameter('now', new \DateTime())->getQuery()->getResult();
foreach ($keys as $key) {
\D::manager()->remove($key);
}
\D::manager()->flush();
}
示例8: getModels
public function getModels()
{
$models = D::queryGoodsModels(array('make' => $this->make, 'series' => $this->series, 'year' => $this->year));
// if (!empty($models)) {
// $add_model = array(array("modelId" => "ALL", "name" => "ALL"));
// $models = array_merge($add_model, $models);
// }
return $models;
}
示例9: cleanOld
public static function cleanOld()
{
$urls = \CMF\Model\URL::select('item')->getQuery()->getResult();
$deleted = 0;
foreach ($urls as $url) {
$item = $url->item();
if (empty($item)) {
\D::manager()->remove($url);
$deleted++;
}
}
\D::manager()->flush();
return $deleted;
}
示例10: action_languageCanonicals
public function action_languageCanonicals()
{
$lang = \Config::get('language');
$em = \D::manager();
if (empty($lang)) {
throw new \Exception("You do not have set any language for this site , this action is not available");
}
$canonicalLanguage = "";
if (isset($_SERVER["HTTP_CONTENT_LANGUAGE"])) {
$canonicalLanguage = $_SERVER["HTTP_CONTENT_LANGUAGE"];
if ($canonicalLanguage == $lang) {
throw new \Exception("Canonical Language id the same as Main site language");
}
} else {
throw new \Exception("The Request has got not language set");
}
$jsonObject = null;
try {
$jsonObject = json_decode(file_get_contents('php://input'));
} catch (\Exception $e) {
}
if (!empty($jsonObject) && !empty($jsonObject->data)) {
foreach ($jsonObject->data as $table => $items) {
foreach ($items as $canonical) {
$class = $canonical->class;
$item = $class::find($canonical->id);
if (!empty($item) && !empty($item->settings)) {
$settings = $item->settings;
if (!isset($settings['languages'])) {
$settings['languages'] = array();
}
if (isset($canonical->url)) {
if (!isset($settings['languages'][$canonicalLanguage])) {
$settings['languages'][$canonicalLanguage] = \Uri::base(false) . $item->url;
}
$settings['languages'][$canonicalLanguage] = $canonical->url;
} else {
if (isset($settings['languages'][$canonicalLanguage])) {
unset($settings['languages'][$canonicalLanguage]);
}
}
$item->set('settings', $settings);
$em->persist($item);
}
}
}
}
$em->flush();
exit(true);
}
示例11: __construct
public function __construct($metadata, $model, $prefix = '', $prepopulate = array(), $exclude = array(), $disable_groups = false, $disable_widgets = false, $extra_settings = null)
{
$class_name = $metadata->name;
$model_id = $model->id;
$this->table_name = $metadata->table['name'];
$this->prepopulate = \Arr::merge(\Input::get(), $prepopulate);
$this->exclude = $exclude;
$this->disable_groups = $disable_groups;
$this->disable_widgets = $disable_widgets;
$this->title = $model_id && method_exists($model, 'getFormTitle') ? $model->getFormTitle() : $class_name::singular();
if (\Input::param('alias', false) !== false) {
$this->icon = 'link';
$this->plural = 'Links';
$this->singular = 'Link';
} else {
$this->icon = $class_name::icon();
$this->plural = $class_name::plural();
$this->singular = $class_name::singular();
}
// Tabs, Groups, Fields
$this->tabs = $class_name::tabs();
$this->groups = $class_name::groups();
$this->default_tab = $class_name::defaultTab();
$this->default_group = $class_name::defaultGroup();
// Merge in extra field settings
$this->fields = \Admin::getFieldSettings($class_name);
if ($extra_settings !== null && is_array($extra_settings)) {
$this->fields = \Arr::merge($this->fields, $extra_settings);
}
$this->validator_meta = \D::validator()->getMetadataFactory()->getMetadataFor($class_name);
// Merge any DB settings into the mix...
$model_settings = $model->settings;
if (is_array($model_settings)) {
$_model_settings = array();
foreach ($model_settings as $key => $value) {
if (is_array($value) && ($metadata->hasField($key) || $metadata->hasAssociation($key))) {
$_model_settings[$key] = $value;
}
}
$this->fields = \Arr::merge($this->fields, $_model_settings);
}
// The field data
$this->processFieldSettings($metadata, $model, $prefix);
// The group data
$this->processGroups();
// The form structure
$this->processFormStructure();
$this->assets['js'] = array_unique($this->assets['js']);
$this->assets['css'] = array_unique($this->assets['css']);
}
示例12: newDb
public function newDb($name) {
$database = $this->libs->Config->get('databases', $name);
//Sweetframework::getClass('lib', 'databases/drivers/' . $database['driver'], );
//App::includeLibrary('Databases/Drivers/' . $database['driver'] . '.php');
$this->setCurrentDb($name);
$this->databases[$name] = Sweetframework::loadClass('lib', 'databases/drivers/' . $database['driver'], $database); //new $database['driver']($database);
if(!$this->databases[$name]->connect()) {
D::warn('failed to connect to the db');
}
}
示例13: startQuery
public function startQuery($sql, array $params = null, array $types = null)
{
if ($this->logger) {
$this->logger->startQuery($sql, $params, $types);
}
// Store select queries for later use
if (substr($sql, 0, 6) == 'SELECT') {
if ($params) {
// Attempt to replace placeholders so that we can log a final SQL query for profiler's EXPLAIN statement
// (this is not perfect-- getPlaceholderPositions has some flaws-- but it should generally work with ORM-generated queries)
$is_positional = is_numeric(key($params));
list($sql, $params, $types) = \Doctrine\DBAL\SQLParserUtils::expandListParameters($sql, $params, $types);
if (empty($types)) {
$types = array();
}
$placeholders = \Doctrine\DBAL\SQLParserUtils::getPlaceholderPositions($sql, $is_positional);
if ($is_positional) {
$map = array_flip($placeholders);
} else {
$map = array();
foreach ($placeholders as $name => $positions) {
foreach ($positions as $pos) {
$map[$pos] = $name;
}
}
}
ksort($map);
$src_pos = 0;
$final_sql = '';
$first_param_index = key($params);
foreach ($map as $pos => $replace_name) {
$final_sql .= substr($sql, $src_pos, $pos - $src_pos);
if ($sql[$pos] == ':') {
$src_pos = $pos + strlen($replace_name);
$index = trim($replace_name, ':');
} else {
$src_pos = $pos + 1;
$index = $replace_name + $first_param_index;
}
$final_sql .= \D::manager()->getConnection()->quote($params[$index], \Arr::get($types, $index));
}
$final_sql .= substr($sql, $src_pos);
$this->queries[] = $final_sql;
} else {
$this->queries[] = $sql;
}
}
}
示例14: set
function set($name) {
//@todo rename this to just set
$newPlace = 'app/themes/' . $name;
D::log(LOC . '/' . $newPlace, 'new Place');
if(is_dir(LOC . '/' . $newPlace)) {
if(substr(URL, -1) == '?') {
T::$url = $this->themeUrl = substr(URL, 0, -1) . $newPlace;
} else {
T::$url = $this->themeUrl = URL . $newPlace;
}
T::$loc = LOC . '/' . $newPlace;
//$this->libs->Config->set('site', 'theme', $newPlace);
return true;
} else {
D::error('Theme doesn\'t exist');
}
}
示例15: instance
/** inheritdoc */
public static function instance()
{
$called_class = get_called_class();
if (!isset($called_class::$instances[$called_class])) {
$result = $called_class::select('item, start_page')->leftJoin('item.start_page', 'start_page')->setMaxResults(1)->getQuery()->getResult();
if (count($result) == 0) {
// Create the item if it doesn't exist
$result = new $called_class();
$result->blank();
\D::manager()->persist($result);
\D::manager()->flush();
$called_class::$instances[$called_class] = $result;
} else {
$called_class::$instances[$called_class] = $result[0];
}
}
return $called_class::$instances[$called_class];
}