好的,所以这不是我第一次创建服务,但我无法解决错误
您已请求不存在的服务"global_settings".
我采取的步骤,以确保正确设置服务
我的 AppBundleExtension.php
namespace AppBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader;
class AppBundleExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('settings.xml');
}
}
Run Code Online (Sandbox Code Playgroud)
我的 settings.xml
<?xml version="1.0" encoding="UTF-8" ?>
<container
xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="global_settings" class="AppBundle\Services\GlobalSettings">
<call method="setEntityManager">
<argument type="service" id="doctrine.orm.default_entity_manager" />
</call>
</service>
</services>
</container>
Run Code Online (Sandbox Code Playgroud)
我的GlobalSettings服务
namespace AppBundle\Services;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
class GlobalSettings …Run Code Online (Sandbox Code Playgroud) parameters.yml我试图从数据库加载它们而不是硬编码参数.并非所有parameters.yml中的参数都需要从数据库加载一些,比如paypal的api细节
在config.yml我已经导入了parameters.php
imports:
- { resource: parameters.php }
Run Code Online (Sandbox Code Playgroud)
如果我parameters.php像下面那样添加静态信息,它可以正常工作
$demoName = 'First Last';
$container->setParameter('demoName', $demoName);
Run Code Online (Sandbox Code Playgroud)
但是我无法从数据库表中获取信息.我以为我应该创建类并使用$em = this->getDoctrine()->getManager();它,它应该工作,但它没有,我得到错误
Notice: Undefined variable: paypal_data in /opt/lampp/htdocs/services/app/config/parameters.php (which is being imported from "/opt/lampp/htdocs/services/app/config/config.yml").
这是我的尝试如下,但代码似乎没有进入 __construct()
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\ORM\Mapping as ORM;
class parameters extends Controller
{
public $paypal_data;
function __construct() {
$this->indexAction();
}
public function indexAction(){
$em = $this->getDoctrine()->getManager();
$this->paypal_data = $em->getRepository('featureBundle:paymentGateways')->findAll();
}
}
$demoName = 'First Last';
$container->setParameter('demoName', $demoName);
$container->setParameter('paypal_data', $this->paypal_data);
Run Code Online (Sandbox Code Playgroud)
任何帮助都感激不尽.
我使用的引导V2.3.2和jQuery 日期选择器 v1.10.0,
在模式上我试图利用日期选择器,它出现在Firefox和IE上的模态背后,在Chrome上似乎工作正常.
这就是它在IE和Firefox上的样子

我的模态HTML
<div id="editGoals" class="modal hide fade" data-keyboard="false" data-backdrop="static">
<div class="modal-header">
<a type="button" class="close" data-dismiss="modal" aria-hidden="true">×</a>
<h3 style="font-size: 18px;" id="myModalLabel"><img src="assets/img/logo_icon.png">Goal Tracker</h3>
</div>
<div class="modal-body">
<div id="message2"></div>
<form action="dashboard-goals-ajax.php" method="post" name="goaldataform" id="goaldataform"
class="form-horizontal goaldataform">
<div class="control-group">
<label class="control-label goal_label_text"><?php _e('Goal Target'); ?>
</label>
<div class="controls">
<div class="input-prepend input-append">
<span class="add-on">$</span><input type="text" class="input-medium" name="goal_target" id="goal_target" value="">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label goal_label_text"><?php _e('How much have you saved towards your goal?'); ?>
</label>
<div class="controls">
<div …Run Code Online (Sandbox Code Playgroud) jquery jquery-ui datepicker twitter-bootstrap bootstrap-modal
我有一个项目正在轨道上5.1.2,我正在尝试在其上实现Active Storage,在线上的几个教程我能够设置Active Storage,我可以看到数据被保存在active_storage_blobs和active_storage_attachments表中.
我也通过跑步确认user.avatar.attached?并且作出回应我得到了真实所以事情正在发挥作用.
我遇到的问题是在视图中显示图像,我试过了
<%= image_tag(url_for(user.avatar)) %>
Run Code Online (Sandbox Code Playgroud)
NoMethodError:未定义的方法`active_storage_attachment_path'
我做了什么来设置Active Storage
跑完安装命令
rails active_storage:install
Run Code Online (Sandbox Code Playgroud)
这给出了错误不知道如何构建任务'active_storage:install'
但以下命令有效
rails activestorage:install
Run Code Online (Sandbox Code Playgroud)
我已经添加了gem 'activestorage'内部gemfile
这就是我的内心 storage_services.yml
test:
service: Disk
root: <%= Rails.root.join("tmp/storage") %>
local:
service: Disk
root: <%= Rails.root.join("storage") %>
Run Code Online (Sandbox Code Playgroud)
在我的内心我development.rb添加了
config.active_storage.service = :local
Run Code Online (Sandbox Code Playgroud)
在我的User模型里面我添加了has_one_attached :avatar
在更新控制器内部,我添加了附件代码
user.avatar.attach(params[:user][:avatar])
Run Code Online (Sandbox Code Playgroud)
但我无法显示它,
我在这里错过了什么?要让图像在视图中显示,我需要做什么?为什么我会收到此错误
NoMethodError:未定义的方法`active_storage_attachment_path'
我正在尝试为客户使用magento rest api.但是当我验证应用程序时,它会给我以下错误.
Invalid auth/bad request (got a 500, expected HTTP/1.1 20X or a redirect)
Service temporary unavailable
Run Code Online (Sandbox Code Playgroud)
我正在尝试为客户角色获取产品集合.
$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/xml'));
Run Code Online (Sandbox Code Playgroud)
代码行抛出异常.
任何帮助将不胜感激.
我在基于 symfony 的 Web 门户上使用 websocket捆绑包,而当我将门户移动到生产服务器上时,一切似乎都在本地主机上工作,但事情却崩溃了。
在本地主机上,我使用的主机127.0.0.1和端口是8080这样的,所以当我转移到生产环境时,我必须将 ip 更改为生产 ip,然后我必须告诉 ubuntu 服务器使用以下命令打开端口 8080
sudo ufw allow 8080/tcp这给了我的输出
Rule added
Rule added (v6)
Run Code Online (Sandbox Code Playgroud)
然后我运行命令sudo ufw status查看端口是否已添加到防火墙中,我可以看到它是
To Action From
-- ------ ----
22 ALLOW Anywhere
80/tcp ALLOW Anywhere
8080 ALLOW Anywhere
8080/tcp ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
8080 (v6) ALLOW Anywhere (v6)
8080/tcp (v6) ALLOW Anywhere (v6)
Run Code Online (Sandbox Code Playgroud)
但是错误仍然存在
WebSocket connection to 'ws://111.222.333.44:8080/' failed: Error in …Run Code Online (Sandbox Code Playgroud) 这是我第一次使用表单的 EventListener,所以我正在努力研究如何在其中注入 EntityManager。
我调用了这个 formTypeUserType并且在这个类中我有一个AddDepartmentDegreeCourseFieldSubscriber需要访问 EntityManager的 EventSubscriber
class UserType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventSubscriber(new AddProfileFieldSubscriber());
$builder->addEventSubscriber(new AddDepartmentDegreeCourseFieldSubscriber());
}
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\User'
));
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的 services.yml
app.department_course_degree_subscriber:
class: AppBundle\Form\EventListener\AddDepartmentDegreeCourseFieldSubscriber
arguments: ["@doctrine.orm.entity_manager"]
tags:
- { name: kernel.event_subscriber }
Run Code Online (Sandbox Code Playgroud)
我得到的错误如下
可捕获的致命错误:传递给 AppBundle\Form\EventListener\AddDepartmentDegreeCourseFieldSubscriber::__construct() 的参数 1 必须是 Doctrine\ORM\EntityManager 的一个实例,没有给出,在 /Users/shairyar/Sites/oxford-portal/src/AppBundle 中调用/Form/UserType.php 在第 …
我正在尝试使用AliceBundle for Symfony Framework生成虚拟数据。除了我正在寻找一种方法将数组中的数据随机分配给名为type. 查看faker 库,我可以看到我可以使用randomElement($array = array ('a','b','c'))
我正在尝试将其转换为YML并且我认为这相当于
<randomElement(['a','b','c'])>
Run Code Online (Sandbox Code Playgroud)
但这会产生错误
[Nelmio\Alice\Throwable\Exception\FixtureBuilder\ExpressionLanguage\LexException] 无法对值“['a'”进行词法分析。
这是我的完整 yml
AppBundle\Entity\Job:
job{1..5}:
title: <jobTitle()>
description: <paragraph(3)>
length: "3_months_full_time"
type: <randomElement(['a','b','c'])>
bonus: <paragraph(3)>
expired_at: "2016-12-21"
job_user: "@emp*"
Run Code Online (Sandbox Code Playgroud) 我有表单事件FormEvents::PRE_SUBMIT到位
namespace AppBundle\Form\EventListener;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
class AddProfileFieldSubscriber implements EventSubscriberInterface
{
protected $authorizationChecker;
protected $em;
function __construct(AuthorizationChecker $authorizationChecker, EntityManager $em)
{
$this->authorizationChecker = $authorizationChecker;
$this->em = $em;
}
public static function getSubscribedEvents()
{
// Tells the dispatcher that you want to listen on the form.pre_set_data
// event and that the preSetData method should be called.
return array(
FormEvents::PRE_SUBMIT => 'onPreSubmit'
);
}
/**
* @param FormEvent $event
*/
public function onPreSubmit(FormEvent …Run Code Online (Sandbox Code Playgroud) 我是Python的新手,仍然在学习技巧。
我如何将以下代码转换为单个内衬,在Python中可以吗?必须有一种整齐的方法来做到这一点。
try:
image_file = self.request.files['image_path']
except:
image_file = None
Run Code Online (Sandbox Code Playgroud) symfony ×6
php ×5
datepicker ×1
doctrine-orm ×1
jquery ×1
jquery-ui ×1
magento ×1
nelmio-alice ×1
oauth ×1
python ×1
python-2.7 ×1
rest ×1
ubuntu-15.10 ×1
websocket ×1