我有一个嵌入了文档的文档.当我第一次创建一个对象时,一切正常,但是当我尝试更新文档时,嵌入的文档不会更新.
/** @MongoDB\Document */
class DocumentA
{
/** @MongoDB\EmbedOne(targetDocument="DocumentB") **/
protected $docB;
/** @MongoDB\String */
protected $valueA;
}
/** @MongoDB\EmbeddedDocument */
class DocumentB
{
/** @MongoDB\String */
protected $valueB;
}
Run Code Online (Sandbox Code Playgroud)
在我的应用程序中,我查询文档,更新值并将它们保存到数据存储中.
// Variant A – Does not work
$document = ... // find from data store
$document->setValueA('Hello World');
$document->getDocB()->setValueB('foo baz');
$om->persist($document);
$om->flush();
Run Code Online (Sandbox Code Playgroud)
如果我不更新嵌入式文档,但设置一个新文件一切正常:
// Variant B - Does work
$document = ... // find from data store
$document->setValueB('Hello World 2');
$document->setDocB(new DocumentB());
$document->getDocB()->setValueB('foo baz 2');
$om->persist($document);
$om->flush();
Run Code Online (Sandbox Code Playgroud)
正如我所说,变体B的工作正常.但是,在我的应用程序中,文档更复杂,每次我必须更新它时,为嵌入式文档创建一个新对象是不切实际的.有没有一种方法可以告诉Doctrine ODM查看嵌入式文档的值以决定是否应该更新它?
我有一个带十六进制代码的文件,我需要从文件中的每个字节获取所有最低有效位,连接它们,将它们分成8组,然后将字节转换为ASCII.我的问题是从每个字节中提取LSB.
hex文件看起来像这样(但更长):
58 00 00 1F 58 00 00 00 00 00 00 00 00 00 00 1C 22 23 1F 26 25 1E 2C 26 20 31 2B 22 38 2F 26 42 36 25 47 37 24 49 39 22
Run Code Online (Sandbox Code Playgroud)
我的代码看起来像这样:
<?php
// Read file, remove spaces
$file = implode('', explode(' ', file_get_contents('vogel.hex')));
// Save LSB
$bits = array();
for ($i = 1; $i < strlen($file); ++$i)
{
$bits[] = $file[$i] & 1;
}
// Split LSB array …Run Code Online (Sandbox Code Playgroud) 我的应用程序由一个被命名为喜欢多束HelloWorldAdminBundle,HelloWorldUserBundle,HelloWorldDemoBundle.这导致在配置根等hello_world_demo,hello_world_user和hello_world_demo.我希望我的捆绑包的配置根源是helloworld_demo,helloworld_user和helloworld_admin.那时我不得不提到这不是一个技术问题,而是一个美学问题.
我试图实现自定义扩展并在Bundle中注册它:
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->registerExtension(new HelloworldDemoExtension());
}
Run Code Online (Sandbox Code Playgroud)
扩展名:
...
class HelloworldDemoExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
}
public function getAlias()
{
return 'hello_world_demo';
}
}
Run Code Online (Sandbox Code Playgroud)
最后是配置:
...
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$treeBuilder = …Run Code Online (Sandbox Code Playgroud) 我有一个包含多个模块的项目(使用Lerna),我想使用Jest来运行测试.但是,当我测试使用共享模块的代码(通过Lerna的npm链接模块)时,似乎Babel未正确应用,我收到以下错误:
SyntaxError: Unexpected token import
Run Code Online (Sandbox Code Playgroud)
我的项目结构如下:
- my-project
|- shared
|- native
|- web
Run Code Online (Sandbox Code Playgroud)
web并native要求该shared模块.当我进入shared目录并在Jest中运行本地测试时,一切正常.如果我在web目录中运行Jest测试,只要我包含了一些内容,就会发生上述错误shared.
这是一个导致错误的超级简单测试:
import { util } from 'shared';
it('returns false if not prod', () => {
expect(util.isProd()).toBe(false);
});
Run Code Online (Sandbox Code Playgroud)
我.babelrc看起来像这样:
{
"presets": [
"env",
"flow",
"react"
],
"plugins": [
"flow-react-proptypes",
"transform-object-rest-spread",
"transform-class-properties"
]
}
Run Code Online (Sandbox Code Playgroud)
我尝试了所有可以找到的东西,包括:
es2015预设和启用modules测试环境的配置transformbabel-jest 的选项shared模块中执行,因此,Jest也babel-jest可以在那里安装.php ×3
babel ×1
doctrine ×1
doctrine-odm ×1
javascript ×1
jest ×1
lerna ×1
mongodb ×1
symfony ×1