My question is about this bundle: https://github.com/nelmio/alice in combination with Symfony2.
I have some fixture i want to load in my new website, and this bundle is great for that. I created some YML files and consider the following YML as my fixturedata:
DateTime (local):
news-date-1:
__construct: ['2014-07-01']
Stef\BVBundle\Entity\Blog:
StefBVBundle-Blog-1:
title: 'A day with blah'
blog: 'e5645646'
image: 'beach.jpg'
author: 'dsyph3r'
tags: 'symfony2, php, paradise, symblog'
created: #news-date-1
updated: #news-date-1
StefBVBundle-Blog-2:
id: 1
title: 'meeeh'
author: dsyph3r
blog: '5rw5425'
image: beach.jpg
tags: 'symfony2, php, paradise, symblog'
created: '2014-07-01T00:00:00+0200'
updated: '2014-07-01T00:00:00+0200'
The one labelled with 'StefBVBundle-Blog-1' works like a charm, it knows 'created' and 'updated' are \DateTime values.
But 'StefBVBundle-Blog-2' causes an error, because the Nemo/Alice bundle consider it as a string, instead of a DateTime. Is it possible to do the DateTime-part inline?
PHP Expressions inside <( )> are simply passed to Doctrine, so this will do the work :
Stef\BVBundle\Entity\Blog:
StefBVBundle-Blog-2:
created: <(new \DateTime('2014-02-02'))>
Regarding the doc of Faker library, you have to specify a DateTime instance, or DateTimeBetween with no time-laps if you want an exact date.
Your code, with correction:
DateTime (local):
news-date-1:
__construct: ['2014-07-01']
Stef\BVBundle\Entity\Blog:
StefBVBundle-Blog-1:
title: 'A day with blah'
blog: 'e5645646'
image: 'beach.jpg'
author: 'dsyph3r'
tags: 'symfony2, php, paradise, symblog'
created: #news-date-1
updated: #news-date-1
StefBVBundle-Blog-2:
id: 1
title: 'meeeh'
author: dsyph3r
blog: '5rw5425'
image: beach.jpg
tags: 'symfony2, php, paradise, symblog'
created: <dateTimeBetween('0 days', '2014-07-01T00:00:00+0200')>
updated: <dateTimeBetween('0 days', '2014-07-01T00:00:00+0200')>
Didn't try, but should work.
Related
I'm trying to generate types from the schema.yaml file, which I created
schema.yaml
types:
product:
properties:
name: {nullable: false}
description: {nullable: false}
image: { range: "Text"}
Offer:
properties:
url: {nullable: false}
price: {nullable: false, range: "Number"}
priceCurrency: {nullable: false}
Then when I execute the following command
vendor/bin/schema generate-types src/ config/schema.yaml
I will receive the following error:
Command "generate-types" is not defined
I tried to know what is the reason but I couldn't find it out.
Where can I defined the command: generate-types
My smfony version is 5.3
thanks a lot
See this changelog:
The generate-types command has been renamed generate
You need to change generate-types to generate.
Here is my YAML:
---
version: 1.0
employee:
name:
employee1
headers:
I have the dict_data as below:-
dict_data = {'Key1': 'value1', 'Key2': 'value2}
Now we have to append this dict to headers attribute in yaml.
And the yaml should look like below:-
---
version: 1.0
employee:
name:
employee1
headers:
Key1: value1
Key2: value2
I tried doing this with PyYaml using update keyword and dumped only the dict in yaml file and removed all other contents.
You can read, update and rewrite as,
with open('filename.yaml','r') as yamlfile:
current_yaml = yaml.safe_load(yamlfile)
current_yaml['headers'].update(dict_data)
if current_yaml:
with open('filename.yaml','w') as yamlfile:
yaml.safe_dump(current_yaml, yamlfile)
I've created a fixture file to test an element that I've created using Dna Design's Silverstripe Elemental package and Silverstripe seems to insist that the has_many relationship 'Elements' in ElementalArea doesn't exist.
SilverStripe\ORM\Connect\DatabaseException: Couldn't run query:
INSERT INTO "ElementalArea"
("Elements")
VALUES
(?)
Unknown column 'Elements' in 'field list'
I have the fixture file:
---
MyElement:
my-element:
...
ElementalArea:
elemental-area:
Elements: =>MyElement.my-element
I've tried running sake /dev/build "flush=all" and clearing /tmp/sivlerstripe-cache... with no luck
In Silverstripe 4 the Elemental module is namespaced. In our fixture yml file we must provide the full namespaced path for ElementalArea.
Also, on a has many relationship we can set the relationship on the has one side (the Element):
DNADesign\Elemental\Models\ElementalArea:
elemental-area:
Title: 'Area 1'
DNADesign\Elemental\Tests\Src\TestPage:
page1:
Title: 'Page 1'
URLSegment: 'test-page'
ElementalAreaID: =>DNADesign\Elemental\Models\ElementalArea.elemental-area
MyElement:
my-element:
Title: 'Element 1'
ParentID: =>DNADesign\Elemental\Models\ElementalArea.elemental-area
I'm trying to learn how to use script plugin. I'm following script plugin docs here but not able to make it work.
I've tried to use the plugin in two ways. The first, when cloudify.interface.lifecycle.start operation is mapped directly to a script:
tosca_definitions_version: cloudify_dsl_1_3
imports:
- 'http://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml'
node_templates:
Import_Project:
type: cloudify.nodes.WebServer
capabilities:
scalable:
properties:
default_instances: 1
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: scripts/create_project.sh
inputs: {}
The second with a direct mapping:
tosca_definitions_version: cloudify_dsl_1_3
imports:
- 'http://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml'
node_templates:
Import_Project:
type: cloudify.nodes.WebServer
capabilities:
scalable:
properties:
default_instances: 1
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: script.script_runner.tasks.run
inputs:
script_path: scripts/create_project.sh
I've created a directory named scripts and placed the below create_project.sh script in this directory:
#! /bin/bash -e
ctx logger info "Hello to this world"
hostname
I'm getting errors while validating the blueprint.
Error when operation is mapped directly to a script:
[2019-04-13 13:29:40.594] [DEBUG] DslParserExecClient - got output from dsl parser Could not extract plugin from operation mapping 'scripts/create_project.sh', which is declared for operation 'start'. In interface 'cloudify.interfaces.lifecycle' in node 'Import_Project' of type 'cloudify.nodes.WebServer'
in: /opt/cloudify-composer/backend/dev/workspace/2/tmp-27O0e1t813N6as
in line: 3, column: 2
path: node_templates.Import_Project
value: {'interfaces': {'cloudify.interfaces.lifecycle': {'start': {'implementation': 'scripts/create_project.sh', 'inputs': {}}}}, 'type': 'cloudify.nodes.WebServer', 'capabilities': {'scalable': {'properties': {'default_instances': 1}}}}
Error when using a direct mapping:
[2019-04-13 13:25:21.015] [DEBUG] DslParserExecClient - got output from dsl parser node 'Import_Project' has no relationship which makes it contained within a host and it has a plugin 'script' with 'host_agent' as an executor. These types of plugins must be installed on a host
in: /opt/cloudify-composer/backend/dev/workspace/2/tmp-279QCz2CV3Y81L
in line: 2, column: 0
path: node_templates
value: {'Import_Project': {'interfaces': {'cloudify.interfaces.lifecycle': {'start': {'implementation': 'script.script_runner.tasks.run', 'inputs': {'script_path': 'scripts/create_project.sh'}}}}, 'type': 'cloudify.nodes.WebServer', 'capabilities': {'scalable': {'properties': {'default_instances': 1}}}}}
What is missing to make this work?
I also found the Cloudify Script Plugin examples from their documentation do not work: https://docs.cloudify.co/4.6/working_with/official_plugins/configuration/script/
However, I found I can make the examples work by adding an executor line in parallel with the implementation line to override the host_agent executor as follows:
tosca_definitions_version: cloudify_dsl_1_3
imports:
- 'http://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml'
node_templates:
Import_Project:
type: cloudify.nodes.WebServer
capabilities:
scalable:
properties:
default_instances: 1
interfaces:
cloudify.interfaces.lifecycle:
start:
implementation: scripts/create_project.sh
executor: central_deployment_agent
inputs: {}
I am trying to create a JSS article using RMarkdown, but am not able to get options that typically get used with pdf_document, in particular, the citecolor option.
Here is an MWE, which is the standard JSS template that ships with the rticles package:
---
author:
- name: FirstName LastName
affiliation: University/Company
address: >
First line
Second line
email: name#company.com
url: http://rstudio.com
- name: Second Author
affiliation: Affiliation
title:
formatted: "A Capitalized Title: Something about a Package \\pkg{foo}"
# If you use tex in the formatted title, also supply version without
plain: "A Capitalized Title: Something about a Package foo"
# For running headers, if needed
short: "\\pkg{foo}: A Capitalized Title"
abstract: >
The abstract of the article.
keywords:
# at least one keyword must be supplied
formatted: [keywords, not capitalized, "\\proglang{Java}"]
plain: [keywords, not capitalized, Java]
preamble: >
\usepackage{amsmath}
output: rticles::jss_article
citecolor: blue
references:
- id: fenner2012a
title: One-click science marketing
author:
- family: Fenner
given: Martin
container-title: Nature Materials
volume: 11
URL: 'http://dx.doi.org/10.1038/nmat3283'
DOI: 10.1038/nmat3283
issue: 4
publisher: Nature Publishing Group
page: 261-263
type: article-journal
issued:
year: 2012
month: 3
---
# Introduction
[#fenner2012a]
# References
This does not highlight the reference to be blue. Do I have to adapt the entire template to change the one parameter?