我有这个代码用于Select2
从输入字段创建一个元素:
var codigo_arancelario = $codigo_arancelario.val();
$codigo_arancelario.select2({
placeholder: "Seleccione un estado",
ajax: {
dataType: 'json',
url: function () {
return Routing.generate('obtenerCodigoArancelario');
},
data: function (codigo_arancelario) {
return {
filtro: codigo_arancelario
}
},
results: function (data) {
var myResults = [];
$.each(data.entities, function (index, item) {
myResults.push({
'id': item.id,
'nombre': item.nombre
});
});
return {
results: myResults
};
}
},
formatNoResults: function () {
return "No se encontró el código";
},
formatAjaxError: function () {
return "No hay conexión con …
Run Code Online (Sandbox Code Playgroud) 我有一些问题,不知道为什么,当我从我的应用程序退出时由FOSUserBundle处理,因为当前会话永远不会被破坏甚至清除,这导致我在登录时导致问题导致我在会话上存储一些数据.这是我的security.yml
样子:
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_USER: ROLE_USER
ROLE_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: /login
check_path: /login_check
default_target_path: home
always_use_default_target_path: true
logout:
path: fos_user_security_logout
target: /
invalidate_session: false
anonymous: ~
access_control:
...
Run Code Online (Sandbox Code Playgroud)
这就是session
密钥的配置方式config.yml
:
session:
# handler_id set to null will use default session handler from php.ini
handler_id: ~
cookie_lifetime: 86400
gc_maxlifetime: 600 # session will expire after 10 minutes …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用OOP方式获取当前日期/时间,如下所示:
$now = new \DateTime(); // 2015-05-24 11:21:36 -> this works fine
Run Code Online (Sandbox Code Playgroud)
我也在同一个对象上加1周,$now
所以我这样做了:
$expireTime = $now->modify('+1 week'); // 2015-05-31 11:21:36 -> this also works fine
Run Code Online (Sandbox Code Playgroud)
如果我这样做,用同样的方法:
echo $now;
// Output: 2015-05-31 11:28:59
// Got wrong value, should be original date without modification
echo $expireTime;
// Output: 2015-05-31 11:28:59
// Got the right value since I have added 1 week
Run Code Online (Sandbox Code Playgroud)
为什么?如何在不修改原始对象的情况下添加一周?
编辑:我通过克隆原始对象并修改克隆的对象找到了解决方案,但我想知道这种行为是否正确以及为什么
我有一个奇怪的问题,我不知道如何解决。我正在调用此URL:http://rperez.local
由于某种原因,找不到某些资源。
此问题仅存在于Microsoft Edge中。我已经在Chrome,Firefox和Internet Explorer 11中测试了相同的URL,它可以正常工作,因此在这种情况下我不知道问题出在哪里。
这是浏览器控制台中出现的错误:
HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier).
GET - http://rperez.local/js/mmi_js/scripts.js?1491850831
dashboard (49,1)
HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier).
GET - http://rperez.local/images/icons/24x24/mail.png
dashboard (140,1)
HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier).
GET - http://rperez.local/images/icons/24x24/office-building.png
dashboard (106,1)
...
GET - http://rperez.local/images/icons/16x16/navigate_open.png …
Run Code Online (Sandbox Code Playgroud) 我需要使用 Docker 设置一个开发人员框,这意味着我将拥有:
这是一个设置,其中多个容器将在“中央服务器”中运行,开发人员将通过 SSH 或 Samba 或任何其他方式(尚未定义)连接到这个“中央服务器”。
以此为一个小例子:
/home/dev1/sources
/home/dev2/sources
cont_dev1 (volumes) => /home/dev1/sources:/var/www/html | port: 8080 | URL: http://dev1.box.com
cont_dev2 (volumes) => /home/dev2/sources:/var/www/html | port: 8081 | URL: http://dev2.box.com
Run Code Online (Sandbox Code Playgroud)
box.com
是分配给“中央服务器”的外部 IP 地址的域。
这背后的想法不是在服务器本身上安装开发工具,这样我们就可以利用 Docker 的优势(在工具之间轻松切换,仅举一个)。
我以前从未这样做过,所以我目前的问题/问题是:
我很确定我的猜测在第二点上是正确的,但对于第一点,我不知道如何实现它。任何例子都会对我有很大帮助,我将不胜感激。
我有以下Doctrine2实体:
<?php
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
/**
* @ORM\Entity
*/
class Account
{
use TimestampableEntity;
/**
* @var integer
*
* @ORM\Id
* @ORM\Column(type="integer", unique=true, nullable=false)
*/
private $id;
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我将Gedmo Timestampable与捆绑包提供的Trait一起使用。一切正常。
当我获取数据并且列updated_at
正以时出现问题。在这种情况下,对象将转换为无效日期,如下所示:NULL
0000-00-00 00:00:00
DateTime
?array (
'RowId' => 26944,
'synchflag' => 1,
'updatedAt' =>
DateTime::__set_state(array(
'date' => '-0001-11-30 00:00:00.000000',
'timezone_type' => 3,
'timezone' => 'UTC',
)),
)
Run Code Online (Sandbox Code Playgroud)
我确实检查过文档,但没有任何帮助(或者,如果您让我知道,至少我没有找到它)
解决这个问题的正确方法是什么?
编辑:
也许正确的问题应该是:如果updated_at
要来的话,0000-00-00 00:00:00 …
我正在将Symfony 3.2项目移植到Symfony 3.3,我想使用DI新功能.我已经阅读了文档,但到目前为止我可以使这个工作.请参阅以下类定义:
use Http\Adapter\Guzzle6\Client;
use Http\Message\MessageFactory;
abstract class AParent
{
protected $message;
protected $client;
protected $api_count_url;
public function __construct(MessageFactory $message, Client $client, string $api_count_url)
{
$this->message = $message;
$this->client = $client;
$this->api_count_url = $api_count_url;
}
public function getCount(string $source, string $object, MessageFactory $messageFactory, Client $client): ?array
{
// .....
}
abstract public function execute(string $source, string $object, int $qty, int $company_id): array;
abstract protected function processDataFromApi(array $entities, int $company_id): array;
abstract protected function executeResponse(array $rows …
Run Code Online (Sandbox Code Playgroud) 我正在编写一个单元测试,我想检查该方法是否publish()
被调用一次或多次。这是我整个测试课的一个片段:
<?php
namespace App\Tests\Unit;
use Aws\Sns\SnsClient;
use Exception;
use PHPUnit\Framework\TestCase;
class MyClassTest extends TestCase
{
/** @var SnsClient */
private $snsClient;
public function setUp(): void
{
$this->snsClient = $this->getMockBuilder(SnsClient::class)->disableOriginalConstructor()->getMock();
}
/**
* @throws Exception
*/
public function testNoCaseIdentifierSns()
{
$this->snsClient->expects($this->once())->method('publish')->with([
[
'doc_id' => 1,
'bucket' => 'some_bucket',
'key' => 'test.tiff/0.png'
],
'topic_arn'
]);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行上面的代码时,出现以下错误:
尝试配置方法“publish”,但无法配置,因为它不存在、尚未指定、是最终的或静态的
我想这里的问题是AWS中的方法定义为@method
(参见此处):
* @method \Aws\Result publish(array $args = [])
Run Code Online (Sandbox Code Playgroud)
可以模拟该方法吗?我在这里缺少什么?
更新
在遵循评论建议后,我将代码转换为以下内容:
$this->snsClient->expects($this->once())->method('__call')->with([
'Message' => json_encode([
'doc_id' => …
Run Code Online (Sandbox Code Playgroud) 我不是前端开发人员,但有时我必须运行一些任务,例如yarn install && yarn build-dev
. 目前我正在运行yarn install
,如下所示,但我无法让它正常工作,并且不知道出了什么问题或如何解决它:
? yarn install
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "ENOTEMPTY: directory not empty, rmdir '/Users/reynierpm/Library/Caches/Yarn/v6/npm-react-popper-tooltip-2.10.1-e10875f31916297c694d64a677d6f8fa0a48b4d1-integrity/node_modules/react-popper-tooltip'".
info If you think this is a bug, please open a bug report with the information provided in "/Users/reynierpm/dev/docker/web/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
warning mini-css-extract-plugin@0.4.2: Invalid bin field for "mini-css-extract-plugin".
Run Code Online (Sandbox Code Playgroud)
到目前为止我尝试过什么?
rm -rf
yarn cache clean …
/login
如果出现以下情况,我需要将所有人重定向到
/
路线(app.php
或app_dev.php
)所以我在我这样做了security.yml
:
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
main:
pattern: ^/
anonymous: ~
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
Run Code Online (Sandbox Code Playgroud)
这个在routing.yml
:
common:
resource: "@CommonBundle/Controller/"
type: …
Run Code Online (Sandbox Code Playgroud) php ×6
symfony ×4
apache ×1
aws-php-sdk ×1
datetime ×1
docker ×1
doctrine ×1
doctrine-orm ×1
html ×1
javascript ×1
jquery ×1
json ×1
node.js ×1
npm ×1
phpunit ×1
session ×1
symfony-2.4 ×1
symfony-3.3 ×1
symfony3.x ×1
webpack ×1
yarnpkg ×1