本文整理汇总了PHP中Finder::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::create方法的具体用法?PHP Finder::create怎么用?PHP Finder::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Finder
的用法示例。
在下文中一共展示了Finder::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getWriteDisplay
/**
* show the data in an input element for editing
*
* @return string
*/
protected function getWriteDisplay()
{
$selectedOptionNames = explode(', ', $this->value);
$output = Html::startTag('div', ['class' => $this->class]);
$connectedClassName = $this->fieldinfo->getConnectedClass();
/** @var BaseConnectionObject $connObj */
$connObj = new $connectedClassName();
$class = $connObj->getOtherClass($this->fieldinfo->getClass());
$obj = Factory::createObject($class);
$connectedFieldName = $this->fieldinfo->getFieldsOfConnectedClass();
$table = DB::table($obj->getTable());
$result = Finder::create($class)->find([$table->getColumn($connectedFieldName), $table->getColumn('LK')]);
foreach ($result as $row) {
$params = [];
$params['value'] = $row['LK'];
$params['type'] = 'checkbox';
$params['class'] = 'checkbox';
$params['name'] = $this->name . '[]';
if (in_array($row[$connectedFieldName], $selectedOptionNames)) {
$params['checked'] = 'checked';
}
$output .= Html::startTag('p') . Html::singleTag('input', $params) . " " . $row[$connectedFieldName] . Html::endTag('p');
}
$output .= Html::endTag('div');
return $output;
}
示例2: setData
/**
* set data
*/
public function setData()
{
$obj = Factory::createObject('News');
$table = DB::table($obj->getTable());
$limit = new base_database_Limit(10);
$order = DB::order($table->getColumn('firstEditTime'));
$finder = Finder::create('news')->setOrder($order)->setlimit($limit);
$this->data = $finder->find();
}
示例3: all
/**
* {@inheritdoc}
*/
public function all() : MapInterface
{
$files = Finder::create()->in($this->path);
$map = new Map('string', FileInterface::class);
foreach ($files as $file) {
$map = $map->put($file->getRelativePathname(), $this->get($file->getRelativePathname()));
}
return $map;
}
示例4: mapFieldValue
public function mapFieldValue($value)
{
$obj = Factory::createObject('vendor');
$table = DB::table($obj->getTable());
$where = DB::where($table->getColumn('name'), DB::term($value));
$finder = Finder::create('vendor')->setWhere($where);
$result = $finder->find(array($table->getColumn('LK')));
if (count($result) > 1) {
throw new base_exception_Mapper(TMS('medexchange.exception.mapper.vendorDuplicatedEntry'));
}
$lkArray = $result[0];
return $lkArray['LK'];
}
示例5: getGroupLKByName
/**
* load the right object by its name
*
* @param $name
* @return mixed|null
* @throws base_database_Exception
*/
public static function getGroupLKByName($name)
{
$table = DB::table('gruppe');
$column = $table->getColumn('name');
$where = DB::where($column, DB::term($name));
$finder = Finder::create('group')->setWhere($where);
$results = $finder->find(array($table->getColumn('LK')));
if (empty($results)) {
return null;
}
$result = $results[0];
return $result['LK'];
}
示例6: execute
/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->file_system = new Filesystem();
$source_dir = __DIR__ . '/../Resources/public/';
if (!file_exists($source_dir)) {
throw new \Exception(sprintf("`%s` is not exists!", $source_dir));
}
$root_dir = dirname($this->getContainer()->getParameter('kernel.root_dir'));
$source_dir = realpath($source_dir);
$target_dir = $root_dir . '/web' . $this->getContainer()->getParameter('sf.web_assets_dir');
$this->ensureDirectoryExists($target_dir . '/js');
$this->ensureDirectoryExists($target_dir . '/css');
$this->ensureDirectoryExists($target_dir . '/img');
$this->ensureDirectoryExists($target_dir . '/fonts');
$this->linkDir($source_dir . '/bootstrap-colorpicker/img', $target_dir . '/img');
$this->linkDir($source_dir . '/bootstrap/fonts', $target_dir . '/fonts');
$this->linkDir($source_dir . '/font-awesome4/fonts', $target_dir . '/fonts');
$this->linkDir($source_dir . '/jstree/themes/default/images', $target_dir . '/css');
$this->symlink($source_dir . '/jcrop/css/Jcrop.gif', $target_dir . '/css/Jcrop.gif');
/**
* copy from Symfony\Bundle\FrameworkBundle\Command\AssetsInstallCommand
*/
if (!function_exists('symlink') && !$input->getOption('nosymlink')) {
throw new \InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.');
}
$filesystem = $this->getContainer()->get('filesystem');
// Create the bundles directory otherwise symlink will fail.
$bundlesDir = $target_dir . '/bundles/';
$filesystem->mkdir($bundlesDir, 0777);
$output->writeln(sprintf('Installing assets as <comment>%s</comment>', !$input->getOption('nosymlink') ? 'symlinks' : 'hard copies'));
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
if (is_dir($originDir = $bundle->getPath() . '/Resources/public')) {
$targetDir = $bundlesDir . preg_replace('/bundle$/', '', strtolower($bundle->getName()));
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
$filesystem->remove($targetDir);
if (!$input->getOption('nosymlink')) {
if (!$input->getOption('norelative')) {
$relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($bundlesDir));
} else {
$relativeOriginDir = $originDir;
}
$filesystem->symlink($relativeOriginDir, $targetDir);
} else {
$filesystem->mkdir($targetDir, 0777);
// We use a custom iterator to ignore VCS files
$filesystem->mirror($originDir, $targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir));
}
}
}
return 0;
}
示例7: loadEntriesForCategory
public function loadEntriesForCategory($catLK)
{
$navEntry = Factory::createObject('NavigationEntry');
$table = DB::table($navEntry->getTable());
$where = DB::where($table->getColumn('category'), DB::intTerm($catLK));
$entries = Finder::create('navigationEntry')->setWhere($where)->find();
$relevantEntries = [];
foreach ($entries as $entry) {
if ($this->_isEntitledForEntry($entry)) {
$relevantEntries[] = $entry;
}
}
return $relevantEntries;
}
示例8: toExternal
public function toExternal($value)
{
if (empty($value)) {
return $value;
}
$className = $this->fi->getConnectedClass();
$obj = Factory::createObject($className);
$table = DB::table($obj->getTable());
$where = DB::where($table->getColumn('LK'), DB::intTerm($value));
$displayField = $this->fi->getFieldsOfConnectedClass();
$result = Finder::create($className)->setWhere($where)->find(array($table->getColumn($displayField)));
if (empty($result)) {
return null;
}
return $result[0][$displayField];
}
示例9: mapFieldValue
/**
* converts a given value to the specified structure
*
* @param $value
* @return mixed
* @throws base_database_Exception
* @throws base_exception_Mapper
*/
public function mapFieldValue($value)
{
$obj = Factory::createObject('TSMCollocgroup');
$table = DB::table($obj->getTable());
$where = DB::where($table->getColumn('name'), DB::term($value));
$where->addAnd($table->getColumn('FK_tsmserver'), DB::term(TSMServerManager::get()->getActualTsmServerLK()));
$finder = Finder::create('TSMCollocgroup')->setWhere($where);
$result = $finder->find(array($table->getColumn('LK')));
if (count($result) > 1) {
throw new base_exception_Mapper(TMS('tsmviewer.exception.mapper.collocgroupDuplicatedEntry'));
}
$lkArray = current($result);
return $lkArray['LK'];
}
示例10: getWriteDisplay
protected function getWriteDisplay()
{
$fi = $this->fieldinfo;
$class = $fi->getConnectedClass();
$connectedField = $fi->getFieldsOfConnectedClass();
$objs = Finder::create($class)->find();
$output = Html::startTag('select', array('class' => $this->class, 'name' => $this->name));
foreach ($objs as $obj) {
$params = [];
$actualFieldValue = $obj[$connectedField];
if ($this->value == $actualFieldValue) {
$params['selected'] = 'selected';
}
$params['value'] = $obj->getLogicalKey();
$output .= Html::startTag('option', $params) . $actualFieldValue . Html::endTag('option');
}
$output .= Html::endTag('select');
return $output;
}
示例11: getData
protected function getData()
{
$requestHelper = $this->controller->getRequestHelper();
$pzn = $requestHelper->getParam('pzn');
$obj = Factory::createObject('medicament');
$table = DB::table($obj->getTable());
$where = DB::where($table->getColumn('pzn'), DB::term($pzn));
$finder = Finder::create('medicament')->setWhere($where);
$result = $finder->find();
if (empty($result)) {
return array();
}
/** @var BaseObject $obj */
$obj = $result[0];
foreach ($obj->getAllFields() as $fi) {
if ($fi->getDisplayClass() == 'system') {
continue;
}
$values[$fi->getFieldName()] = $obj->getField($fi->getFieldName());
}
return $values;
}
示例12: executeRequest
/**
* execute the actual ajax request
*/
protected function executeRequest()
{
$requestHelper = $this->controller->getRequestHelper();
$class = $requestHelper->getParam('class');
$object = Factory::createObject($class);
/** @var BaseObject[] $result */
$result = Finder::create($class)->find();
$urlColumns = $requestHelper->getParam('cols');
if (!is_null($urlColumns)) {
if ($urlColumns == 'all') {
$fi = new Fieldinfo($class);
$columnNames = $fi->getAllFieldNames();
} else {
$columnNames = explode(',', $urlColumns);
}
} else {
$columnNames = $object->getStdSearchColumns();
}
$response = new stdClass();
$i = 0;
foreach ($result as $obj) {
$values = [];
$values['LK'] = (int) $obj['LK'];
foreach ($columnNames as $colName) {
$values[$colName] = $obj->getField($colName);
}
$response->BaseObjectReader[] = $values;
$i++;
}
$jsonObject = json_encode($response);
echo $jsonObject;
exit();
}
示例13: login
/**
* login of an user with the given userid and password
*
* @param string $userid
* @param string $password
*
* @return int
* @throws base_database_Exception
*/
public static function login($userid, $password)
{
$table = DB::table(Factory::createObject('user')->getTable());
$where = DB::where($table->getColumn('userid'), DB::stringTerm($userid));
$res = Finder::create('user')->setWhere($where)->find();
if (empty($res)) {
return self::LOGIN_FAILURE;
}
$user = current($res);
if ($user['disabled'] == self::USER_DISABLED) {
return self::LOGIN_USER_DISABLED;
}
if ($user['password'] != md5($password)) {
return self::_updateLoginTries($table, $user);
}
try {
$time = new base_date_model_DateTime();
$updateData = array(
'ip' => DB::stringTerm($_SERVER['REMOTE_ADDR']),
'sessionid' => DB::stringTerm(session_id()),
'lastLogin' => DB::stringTerm($time->toDB()),
'loginTries' => DB::intTerm(0),
);
self::_updateUserLoginData($table, $where, $updateData);
} catch (Exception $e) {
return self::LOGIN_FAILURE;
}
$user['ip'] = $_SERVER['REMOTE_ADDR'];
$user['sessionid'] = session_id();
$user['lastLogin'] = $time;
$user['loginTries'] = 0;
$_SESSION['user'] = $user;
return self::LOGIN_SUCCESS;
}
示例14: getExistingObjects
/**
* @param $where
* @return int
*/
private function getExistingObjects($where)
{
$table = DB::table($this->obj->getTable());
$colPK = $table->getColumn('PK');
$finder = Finder::create(get_class($this->obj));
$result = $finder->setWhere($where)->find(array($colPK));
if (empty($result)) {
return null;
}
return $result[0]['PK'];
}
示例15: execute
/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!function_exists('symlink') && !$input->getOption('nosymlink')) {
throw new \InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.');
}
$this->file_system = new Filesystem();
$assets_root_dir = $this->getContainer()->getParameter('sf.web_root_dir') . $this->getContainer()->getParameter('sf.web_assets_dir');
$this->ensureDirectoryExists($assets_root_dir);
$assets_root_dir = realpath($assets_root_dir);
$filesystem = $this->getContainer()->get('filesystem');
$bundlesDir = $assets_root_dir . '/bundles/';
$this->ensureDirectoryExists($bundlesDir);
$output->writeln(sprintf('Installing assets as <comment>%s</comment>', !$input->getOption('nosymlink') ? 'symlinks' : 'hard copies'));
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
if (is_dir($originDir = $bundle->getPath() . '/Resources/public')) {
$targetDir = $bundlesDir . preg_replace('/bundle$/', '', strtolower($bundle->getName()));
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
$filesystem->remove($targetDir);
if (!$input->getOption('nosymlink')) {
if (!$input->getOption('norelative')) {
$relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($bundlesDir));
} else {
$relativeOriginDir = $originDir;
}
$filesystem->symlink($relativeOriginDir, $targetDir);
} else {
$filesystem->mkdir($targetDir, 0777);
// We use a custom iterator to ignore VCS files
$filesystem->mirror($originDir, $targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir));
}
}
}
/**
* @var $factory \Symforce\CoreBundle\Assets\SymforceAssetsCompiler
*/
$compiler = $this->getContainer()->get('sf.compiler.assets');
$output->writeln(sprintf('Installing assets from <comment>%s</comment>', $compiler->getTagName()));
$twig_parser = $this->getContainer()->get('templating.name_parser');
$twig_locator = $this->getContainer()->get('templating.locator');
$assets_target_dirs = $this->getContainer()->getParameter('sf.web_assets_target_dirs');
/**
* @var $assets_resource \Symforce\CoreBundle\Assets\SymforceAssetsResource
*/
foreach ($compiler->getResources() as $service_id => $assets_resource) {
if (!in_array($assets_resource->getTarget(), $assets_target_dirs)) {
throw new \Exception(sprintf("service(%s) with tags(name=%s, target=%s) target must be one of(%s)", $service_id, $compiler->getTagName(), $assets_resource->getTarget(), join(',', $assets_target_dirs)));
}
$path = $assets_resource->getPath();
try {
$_path = $twig_locator->locate($twig_parser->parse($path));
} catch (\InvalidArgumentException $e) {
throw new \Exception(sprintf("service(%s) with tags(name=%s, path=%s): %s", $service_id, $compiler->getTagName(), $path, $e->getMessage()));
}
$_target_dir = $assets_root_dir . '/' . $assets_resource->getTarget();
$this->ensureDirectoryExists($_target_dir);
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s/%s</comment>', $path, $this->getContainer()->getParameter('sf.web_assets_dir'), $assets_resource->getTarget()));
if (is_dir($_path)) {
$this->linkDir($_path, $_target_dir, $assets_resource->getExtension());
} else {
$this->symlink($_path, $_target_dir . '/' . basename($_path));
}
}
return 0;
}