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


PHP BundleInterface::getNamespace方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpKernel\Bundle\BundleInterface::getNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP BundleInterface::getNamespace方法的具体用法?PHP BundleInterface::getNamespace怎么用?PHP BundleInterface::getNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpKernel\Bundle\BundleInterface的用法示例。


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

示例1: generate

 /**
  * Generates the entity form class if it does not exist.
  *
  * @param BundleInterface $bundle The bundle in which to create the class
  * @param string $entity The entity relative class name
  * @param ClassMetadataInfo $metadata The entity metadata class
  */
 public function generate(BundleInterface $bundle, $entity, $fields, $options = null, $search = false)
 {
     $parts = explode('\\', $entity);
     $entityClass = array_pop($parts);
     $this->className = $entityClass . 'Type';
     $dirPath = $bundle->getPath() . '/Form';
     if ($search) {
         $className = $entityClass . 'SearchType';
         $this->classPath = $dirPath . '/' . str_replace('\\', '/', $entity) . 'SearchType.php';
     } else {
         $className = $entityClass . 'Type';
         $this->classPath = $dirPath . '/' . str_replace('\\', '/', $entity) . 'Type.php';
     }
     if (file_exists($this->classPath)) {
         unlink($this->classPath);
         //throw new \RuntimeException(sprintf('Unable to generate the %s form class as it already exists under the %s file', $this->className, $this->classPath));
     }
     $choice = false;
     foreach ($fields as $field) {
         if ($field['fragment'] == 'choice') {
             $choice = true;
         }
     }
     $parts = explode('\\', $entity);
     array_pop($parts);
     $this->renderFile($this->skeletonDir, 'FormType_tab.php', $this->classPath, array('dir' => $this->skeletonDir, 'fields' => $fields, 'namespace' => $bundle->getNamespace(), 'entity_namespace' => implode('\\', $parts), 'form_class' => $className, 'form_type_name' => strtolower(str_replace('\\', '_', $bundle->getNamespace()) . ($parts ? '_' : '') . implode('_', $parts) . '_' . $this->className), 'entityName' => $entityClass, 'choice' => $choice, 'options' => $options));
 }
开发者ID:r4cker,项目名称:lowbi,代码行数:34,代码来源:DoctrineFormGenerator.php

示例2: generate

 /**
  * Generate Fixture from bundle name, entity name, fixture name and ids
  *
  * @param BundleInterface $bundle
  * @param string          $entity
  * @param string          $name
  * @param array           $ids
  * @param string|null     $connectionName
  */
 public function generate(BundleInterface $bundle, $entity, $name, array $ids, $order, $connectionName = null)
 {
     // configure the bundle (needed if the bundle does not contain any Entities yet)
     $config = $this->registry->getManager($connectionName)->getConfiguration();
     $config->setEntityNamespaces(array_merge(array($bundle->getName() => $bundle->getNamespace() . '\\Entity'), $config->getEntityNamespaces()));
     $fixtureFileName = $this->getFixtureFileName($entity, $name, $ids);
     $entityClass = $this->registry->getAliasNamespace($bundle->getName()) . '\\' . $entity;
     $fixturePath = $bundle->getPath() . '/DataFixtures/ORM/' . $fixtureFileName . '.php';
     $bundleNameSpace = $bundle->getNamespace();
     if (file_exists($fixturePath)) {
         throw new \RuntimeException(sprintf('Fixture "%s" already exists.', $fixtureFileName));
     }
     $class = new ClassMetadataInfo($entityClass);
     $fixtureGenerator = $this->getFixtureGenerator();
     $fixtureGenerator->setFixtureName($fixtureFileName);
     $fixtureGenerator->setBundleNameSpace($bundleNameSpace);
     $fixtureGenerator->setMetadata($class);
     $fixtureGenerator->setFixtureOrder($order);
     /** @var EntityManager $em */
     $em = $this->registry->getManager($connectionName);
     $repo = $em->getRepository($class->rootEntityName);
     if (empty($ids)) {
         $items = $repo->findAll();
     } else {
         $items = $repo->findById($ids);
     }
     $fixtureGenerator->setItems($items);
     $fixtureCode = $fixtureGenerator->generateFixtureClass($class);
     $this->filesystem->mkdir(dirname($fixturePath));
     file_put_contents($fixturePath, $fixtureCode);
 }
开发者ID:GMBN,项目名称:DoctrineFixturesGeneratorBundle,代码行数:40,代码来源:DoctrineFixtureGenerator.php

示例3: getBundleMetadata

 /**
  * Gets the metadata of all classes of a bundle.
  *
  * @param BundleInterface $bundle A BundleInterface instance
  *
  * @return ClassMetadataCollection A ClassMetadataCollection instance
  */
 public function getBundleMetadata(BundleInterface $bundle)
 {
     $namespace = $bundle->getNamespace();
     if (!($metadata = $this->getMetadataForNamespace($namespace))) {
         throw new \RuntimeException(sprintf('Bundle "%s" does not contain any mapped entities.', $bundle->getName()));
     }
     $path = $this->getBasePathForClass($bundle->getName(), $bundle->getNamespace(), $bundle->getPath());
     $metadata->setPath($path);
     $metadata->setNamespace($bundle->getNamespace());
     return $metadata;
 }
开发者ID:rfc1483,项目名称:blog,代码行数:18,代码来源:MetadataFactory.php

示例4: getClasses

 /**
  * @param $dirs
  * @param array $classes
  * @param array $excludeClasses
  * @param string $pattern
  * @return array
  */
 protected function getClasses($dirs, $classes = array(), $excludeClasses = array(), $pattern = '*.php')
 {
     $basePath = $this->bundle->getPath();
     $dirs = array_map(function ($dir) use($basePath) {
         return $basePath . '/' . $dir;
     }, $dirs);
     $allClasses = $this->classFinder->findClasses($dirs, $basePath, $this->bundle->getNamespace(), $pattern);
     $allClasses = array_unique(array_merge($classes, $allClasses));
     return array_filter($allClasses, function ($class) use($excludeClasses) {
         return !in_array($class, $excludeClasses);
     });
 }
开发者ID:kendoctor,项目名称:KndRadBundle,代码行数:19,代码来源:RegisterAutoInjectServicePass.php

示例5: addResource

 /**
  * Adds a Manager service within the managers config file.
  *
  * @param BundleInterface $bundle
  * @param string $entity
  *
  * @return Boolean true if it worked, false otherwise
  *
  * @throws \RuntimeException If bundle is already imported
  */
 public function addResource(BundleInterface $bundle, $entity)
 {
     $managerService = sprintf('%s.manager.%s', Container::underscore(substr($bundle->getName(), 0, -6)), strtolower($entity));
     $managerClass = sprintf('%s\\Manager\\%sManager', $bundle->getNamespace(), ucfirst($entity));
     $entityClass = sprintf('%s\\Entity\\%s', $bundle->getNamespace(), ucfirst($entity));
     $content = Yaml::parse(file_get_contents($this->file));
     $content['parameters'][$managerService . '.class'] = $managerClass;
     $content['services'][$managerService] = array('class' => "%{$managerService}.class%", 'tags' => array(array('name' => 'voryx.manager')), 'arguments' => array($entityClass));
     $yaml = Yaml::dump($content, 4);
     if (false === file_put_contents($this->file, $yaml)) {
         return false;
     }
     return true;
 }
开发者ID:testabit,项目名称:restgeneratorbundle,代码行数:24,代码来源:ManagerManipulator.php

示例6: addResource

 /**
  * Adds an Admin service within the admin config file.
  *
  * @param BundleInterface $bundle
  * @param string $entity
  * @param string $group
  * @param string $label
  * @param string $translationDomain
  *
  * @return Boolean true if it worked, false otherwise
  *
  * @throws \RuntimeException If bundle is already imported
  */
 public function addResource(BundleInterface $bundle, $entity, $group, $label, $translationDomain = 'Sonata')
 {
     $adminService = sprintf('%s.admin.%s', Container::underscore(substr($bundle->getName(), 0, -6)), strtolower($entity));
     $adminClass = sprintf('%s\\Admin\\%sAdmin', $bundle->getNamespace(), ucfirst($entity));
     $entityClass = sprintf('%s\\Entity\\%s', $bundle->getNamespace(), ucfirst($entity));
     $content = Yaml::parse(file_get_contents($this->file));
     $content['parameters'][$adminService . '.class'] = $adminClass;
     $content['services'][$adminService] = array('class' => "%{$adminService}.class%", 'tags' => array(array('name' => 'sonata.admin', 'manager_type' => 'orm', 'group' => $group, 'label' => $label)), 'arguments' => array(null, $entityClass, null), 'calls' => array(array('setTranslationDomain', array($translationDomain))));
     $yaml = Yaml::dump($content, 4);
     if (false === file_put_contents($this->file, $yaml)) {
         return false;
     }
     return true;
 }
开发者ID:testabit,项目名称:restgeneratorbundle,代码行数:27,代码来源:AdminManipulator.php

示例7: generate

 public function generate(BundleInterface $bundle, $controller, $routeFormat, $templateFormat, array $actions = array())
 {
     $dir = $bundle->getPath();
     $controllerFile = $dir . '/Controller/' . $controller . 'Controller.php';
     if (file_exists($controllerFile)) {
         throw new \RuntimeException(sprintf('Controller "%s" already exists', $controller));
     }
     // seeRoute
     $bundleShortName = substr($bundle->getName(), strlen('Webobs'), strlen($bundle->getName()) - (strlen('Bundle') + strlen('Webobs')));
     $seeRoute = 'webobs_' . strtolower($bundleShortName) . '_' . strtolower($controller) . '_see';
     $parameters = array('namespace' => $bundle->getNamespace(), 'bundle' => $bundle->getName(), 'format' => array('routing' => $routeFormat, 'templating' => $templateFormat), 'entity' => $controller, 'seeRoute' => $seeRoute);
     foreach ($actions as $i => $action) {
         // get the actioname without the sufix Action (for the template logical name)
         $actions[$i]['basename'] = $action['name'];
         $params = $parameters;
         $params['action'] = $actions[$i];
         // create a template
         $template = $actions[$i]['template'];
         if ('default' == $template) {
             $template = $bundle->getName() . ':' . $controller . ':' . $action['name'] . '.html.' . $templateFormat;
         }
         $this->generateRouting($bundle, $controller, $actions[$i], $routeFormat);
     }
     $parameters['actions'] = $actions;
     $this->renderFile('controller/Controller.php.twig', $controllerFile, $parameters);
     $this->renderFile('controller/ControllerTest.php.twig', $dir . '/Tests/Controller/' . $controller . 'ControllerTest.php', $parameters);
 }
开发者ID:blacksad12,项目名称:oliorga,代码行数:27,代码来源:ControllerGenerator.php

示例8: generateRestRouting

 public function generateRestRouting(BundleInterface $bundle, $controller)
 {
     $file = $bundle->getPath() . '/Resources/config/routing.rest.yml';
     if (file_exists($file)) {
         $content = file_get_contents($file);
     } elseif (!is_dir($dir = $bundle->getPath() . '/Resources/config')) {
         mkdir($dir);
     }
     $resource = $bundle->getNamespace() . "\\Controller\\" . $controller . 'Controller';
     $name = strtolower(preg_replace('/([A-Z])/', '_\\1', $bundle->getName() . $controller . '_rest'));
     $name_prefix = strtolower(preg_replace('/([A-Z])/', '_\\1', $bundle->getName() . '_api_'));
     if (!isset($content)) {
         $content = '';
     } else {
         $yml = new Yaml();
         $route = $yml->parse($content);
         if (isset($route[$name])) {
             return false;
         }
     }
     $content .= sprintf("\n%s:\n    type: rest\n    resource: %s\n    name_prefix: %s\n", $name, $resource, $name_prefix);
     $flink = fopen($file, 'w');
     if ($flink) {
         $write = fwrite($flink, $content);
         if ($write) {
             fclose($flink);
         } else {
             throw new \RunTimeException(sprintf('We cannot write into file "%s", has that file the correct access level?', $file));
         }
     } else {
         throw new \RunTimeException(sprintf('Problems with generating file "%s", did you gave write access to that directory?', $file));
     }
 }
开发者ID:asiragusa,项目名称:extjs-bundle,代码行数:33,代码来源:RestControllerGenerator.php

示例9: generate

    /**
     * Generates the entity form class if it does not exist.
     *
     * @param BundleInterface $bundle The bundle in which to create the class
     * @param string $entity The entity relative class name
     * @param ClassMetadataInfo $metadata The entity metadata class
     */
    public function generate(BundleInterface $bundle, $entity, ClassMetadataInfo $metadata)
    {
        $parts       = explode('\\', $entity);
        $entityClass = array_pop($parts);

        $this->className = $entityClass.'Type';
        $dirPath         = $bundle->getPath().'/Form';
        $this->classPath = $dirPath.'/'.str_replace('\\', '/', $entity).'Type.php';

        if (file_exists($this->classPath)) {
            throw new \RuntimeException(sprintf('Unable to generate the %s form class as it already exists under the %s file', $this->className, $this->classPath));
        }

        if (count($metadata->identifier) > 1) {
            throw new \RuntimeException('The form generator does not support entity classes with multiple primary keys.');
        }

        $parts = explode('\\', $entity);
        array_pop($parts);

        $this->renderFile($this->skeletonDir, 'FormType.php', $this->classPath, array(
            'dir'              => $this->skeletonDir,
            'fields'           => $this->getFieldsFromMetadata($metadata),
            'namespace'        => $bundle->getNamespace(),
            'entity_namespace' => implode('\\', $parts),
            'form_class'       => $this->className,
        ));
    }
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:35,代码来源:DoctrineFormGenerator.php

示例10: installBundleAssets

 /**
  * {@inheritdoc}
  */
 public function installBundleAssets(BundleInterface $bundle, $targetDir, $symlinkMask)
 {
     $this->output->writeln(sprintf('Installing assets for <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
     $effectiveSymlinkMask = $this->assetsInstaller->installBundleAssets($bundle, $targetDir, $symlinkMask);
     $this->output->writeln($this->provideResultComment($symlinkMask, $effectiveSymlinkMask));
     return $effectiveSymlinkMask;
 }
开发者ID:Sylius,项目名称:SyliusThemeBundle,代码行数:10,代码来源:OutputAwareAssetsInstaller.php

示例11: generate

 public function generate(BundleInterface $bundle, $controller, $routeFormat, $templateFormat, array $actions = array())
 {
     $dir = $bundle->getPath();
     $controllerFile = $dir . '/Controller/' . $controller . 'Controller.php';
     if (file_exists($controllerFile)) {
         throw new \RuntimeException(sprintf('Controller "%s" already exists', $controller));
     }
     $parameters = array('namespace' => $bundle->getNamespace(), 'bundle' => $bundle->getName(), 'format' => array('routing' => $routeFormat, 'templating' => $templateFormat), 'controller' => $controller);
     foreach ($actions as $i => $action) {
         // get the action name without the suffix Action (for the template logical name)
         $actions[$i]['basename'] = substr($action['name'], 0, -6);
         $params = $parameters;
         $params['action'] = $actions[$i];
         // create a template
         $template = $actions[$i]['template'];
         if ('default' == $template) {
             @trigger_error('The use of the "default" keyword is deprecated. Use the real template name instead.', E_USER_DEPRECATED);
             $template = $bundle->getName() . ':' . $controller . ':' . strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), strtr(substr($action['name'], 0, -6), '_', '.'))) . '.html.' . $templateFormat;
         }
         if ('twig' == $templateFormat) {
             $this->renderFile('controller/Template.html.twig.twig', $dir . '/Resources/views/' . $this->parseTemplatePath($template), $params);
         } else {
             $this->renderFile('controller/Template.html.php.twig', $dir . '/Resources/views/' . $this->parseTemplatePath($template), $params);
         }
         $this->generateRouting($bundle, $controller, $actions[$i], $routeFormat);
     }
     $parameters['actions'] = $actions;
     $this->renderFile('controller/Controller.php.twig', $controllerFile, $parameters);
     $this->renderFile('controller/ControllerTest.php.twig', $dir . '/Tests/Controller/' . $controller . 'ControllerTest.php', $parameters);
 }
开发者ID:adrienlucas,项目名称:SensioGeneratorBundle,代码行数:30,代码来源:ControllerGenerator.php

示例12: generateSectionConfig

 /**
  * Update the page section config files
  */
 private function generateSectionConfig()
 {
     if (count($this->sections) > 0) {
         $dir = $this->bundle->getPath() . '/Resources/config/pageparts/';
         foreach ($this->sections as $section) {
             $data = Yaml::parse($dir . $section);
             if (!array_key_exists('types', $data)) {
                 $data['types'] = array();
             }
             $class = $this->bundle->getNamespace() . '\\Entity\\PageParts\\' . $this->entity;
             $found = false;
             foreach ($data['types'] as $type) {
                 if ($type['class'] == $class) {
                     $found = true;
                 }
             }
             if (!$found) {
                 $data['types'][] = array('name' => str_replace('PagePart', '', $this->entity), 'class' => $class);
             }
             $ymlData = Yaml::dump($data, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false);
             file_put_contents($dir . $section, $ymlData);
         }
         $this->assistant->writeLine('Updating ' . $this->entity . ' section config: <info>OK</info>');
     }
 }
开发者ID:rifer,项目名称:KunstmaanBundlesCMS,代码行数:28,代码来源:DefaultPagePartGenerator.php

示例13: generate

 public function generate(BundleInterface $bundle, $controller, $routeFormat, $templateFormat, array $actions = array())
 {
     $dir = $bundle->getPath();
     $controllerFile = $dir . '/Controller/' . $controller . 'Controller.php';
     if (file_exists($controllerFile)) {
         throw new \RuntimeException(sprintf('Controller "%s" already exists', $controller));
     }
     $parameters = array('namespace' => $bundle->getNamespace(), 'bundle' => $bundle->getName(), 'format' => array('routing' => $routeFormat, 'templating' => $templateFormat), 'controller' => $controller);
     foreach ($actions as $i => $action) {
         // get the actioname without the sufix Action (for the template logical name)
         $actions[$i]['basename'] = substr($action['name'], 0, -6);
         $params = $parameters;
         $params['action'] = $actions[$i];
         // create a template
         $template = $actions[$i]['template'];
         if ('default' == $template) {
             $template = $bundle->getName() . ':' . $controller . ':' . substr($action['name'], 0, -6) . '.html.' . $templateFormat;
         }
         if ('twig' == $templateFormat) {
             $this->renderFile('controller/Template.html.twig.twig', $dir . '/Resources/views/' . $this->parseTemplatePath($template), $params);
         } else {
             $this->renderFile('controller/Template.html.php.twig', $dir . '/Resources/views/' . $this->parseTemplatePath($template), $params);
         }
         $this->generateRouting($bundle, $controller, $actions[$i], $routeFormat);
     }
     $parameters['actions'] = $actions;
     $this->renderFile('controller/Controller.php.twig', $controllerFile, $parameters);
     $this->renderFile('controller/ControllerTest.php.twig', $dir . '/Tests/Controller/' . $controller . 'ControllerTest.php', $parameters);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:29,代码来源:ControllerGenerator.php

示例14: generateEntity

 /**
  * Generate the entity PHP code.
  *
  * @param BundleInterface $bundle
  * @param string          $name
  * @param array           $fields
  * @param string          $namePrefix
  * @param string          $dbPrefix
  * @param string|null     $extendClass
  *
  * @return array
  * @throws \RuntimeException
  */
 protected function generateEntity(BundleInterface $bundle, $name, $fields, $namePrefix, $dbPrefix, $extendClass = null)
 {
     // configure the bundle (needed if the bundle does not contain any Entities yet)
     $config = $this->registry->getManager(null)->getConfiguration();
     $config->setEntityNamespaces(array_merge(array($bundle->getName() => $bundle->getNamespace() . '\\Entity\\' . $namePrefix), $config->getEntityNamespaces()));
     $entityClass = $this->registry->getAliasNamespace($bundle->getName()) . '\\' . $namePrefix . '\\' . $name;
     $entityPath = $bundle->getPath() . '/Entity/' . $namePrefix . '/' . str_replace('\\', '/', $name) . '.php';
     if (file_exists($entityPath)) {
         throw new \RuntimeException(sprintf('Entity "%s" already exists.', $entityClass));
     }
     $class = new ClassMetadataInfo($entityClass, new UnderscoreNamingStrategy());
     foreach ($fields as $fieldSet) {
         foreach ($fieldSet as $fieldArray) {
             foreach ($fieldArray as $field) {
                 if (array_key_exists('joinColumn', $field)) {
                     $class->mapManyToOne($field);
                 } elseif (array_key_exists('joinTable', $field)) {
                     $class->mapManyToMany($field);
                 } else {
                     $class->mapField($field);
                 }
             }
         }
     }
     $class->setPrimaryTable(array('name' => strtolower($dbPrefix . strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name))) . 's'));
     $entityCode = $this->getEntityGenerator($extendClass)->generateEntityClass($class);
     return array($entityCode, $entityPath);
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:41,代码来源:KunstmaanGenerator.php

示例15: generate

 /**
  * @param BundleInterface $bundle         The bundle
  * @param string          $entity         The entity name
  * @param string          $format         The format
  * @param array           $fields         The fields
  * @param boolean         $withRepository With repository
  * @param string          $prefix         A prefix
  *
  * @throws \RuntimeException
  */
 public function generate(BundleInterface $bundle, $entity, $format, array $fields, $withRepository, $prefix)
 {
     // configure the bundle (needed if the bundle does not contain any Entities yet)
     $config = $this->registry->getManager(null)->getConfiguration();
     $config->setEntityNamespaces(array_merge(array($bundle->getName() => $bundle->getNamespace() . '\\Entity'), $config->getEntityNamespaces()));
     $entityClass = $this->registry->getAliasNamespace($bundle->getName()) . '\\' . $entity;
     $entityPath = $bundle->getPath() . '/Entity/' . str_replace('\\', '/', $entity) . '.php';
     if (file_exists($entityPath)) {
         throw new \RuntimeException(sprintf('Entity "%s" already exists.', $entityClass));
     }
     $class = new ClassMetadataInfo($entityClass);
     if ($withRepository) {
         $entityClass = preg_replace('/\\\\Entity\\\\/', '\\Repository\\', $entityClass, 1);
         $class->customRepositoryClassName = $entityClass . 'Repository';
     }
     foreach ($fields as $field) {
         $class->mapField($field);
     }
     $class->setPrimaryTable(array('name' => $prefix . $this->getTableNameFromEntityName($entity)));
     $entityGenerator = $this->getEntityGenerator();
     $entityCode = $entityGenerator->generateEntityClass($class);
     $mappingPath = $mappingCode = false;
     $this->filesystem->mkdir(dirname($entityPath));
     file_put_contents($entityPath, $entityCode);
     if ($mappingPath) {
         $this->filesystem->mkdir(dirname($mappingPath));
         file_put_contents($mappingPath, $mappingCode);
     }
     if ($withRepository) {
         $path = $bundle->getPath() . str_repeat('/..', substr_count(get_class($bundle), '\\'));
         $this->getRepositoryGenerator()->writeEntityRepositoryClass($class->customRepositoryClassName, $path);
     }
     $this->addGeneratedEntityClassLoader($entityClass, $entityPath);
 }
开发者ID:axelvnk,项目名称:KunstmaanBundlesCMS,代码行数:44,代码来源:DoctrineEntityGenerator.php


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