我想要实现的是创建/编辑用户工具.可编辑的字段是:
注意:最后一个属性未命名为$ roles因为我的User类正在扩展FOSUserBundle的User类并且覆盖角色带来了更多问题.为了避免它们,我只是决定将我的角色集合存储在$ avoRoles下.
我的模板由两部分组成:
注意:findAllRolesExceptOwnedByUser()是一个自定义存储库函数,返回所有角色的子集(尚未分配给$ user的角色).
1.3.1添加角色:
WHEN user clicks "+" (add) button in Roles table
THEN jquery removes that row from Roles table
AND jquery adds new list item to User form (avoRoles list)
1.3.2删除角色:
WHEN user clicks "x" (remove) button in User form (avoRoles list)
THEN jquery removes that list item from User form (avoRoles list)
AND jquery … 注意我已经研究了git-is-very-slow-slow问题,但在他们的情况下,原因是大的二进制文件 - 而在我的存储库中有PHP/JS/HTML/CSS唯一的代码(没有二进制文件)和最大的文件在存储库中大约800 KB.
我已经改变了一个文件(几行),然后git add .和git commit -m "msg",然后git push origin master.
在其他一些机器上,当我这样做时,git pull origin master它会下载一些MiB数据,计算增量并应用更改需要2分钟以上.这里有些非常错误.
我怀疑最近的一些操作可能会导致这种情况:
最近,bower_components当我意识到它时,我偶然添加了许多供应商资产(资产),我曾经git rm将它们从存储库中删除(当然git add,git commit还有git push上游)
那是几天前,我现在遇到的问题就是在那个时候开始发生的.
我有两个问题:
注意:我是唯一一个使用和推送这个回购的人.
我正在学习AngularJS并玩教程.
我正在修改教程示例过滤器以返回一些字符串:
angular.module('phonecatFilters', []).filter('checkmark', function() {
return function(input) {
return input ? 'true-class' : 'false-class';
};
});
Run Code Online (Sandbox Code Playgroud)
我想用它ngClass如下:
{{phone.trueVal | checkmark}} <i ng-class="{{phone.trueVal | checkmark }}"></i>
{{phone.falseVal | checkmark}} <i ng-class="{{phone.falseVal | checkmark }}"></i>
Run Code Online (Sandbox Code Playgroud)
结果:
true-class <i class="false-class">
false-class <i class="false-class">
Run Code Online (Sandbox Code Playgroud)
现在..而对于简单的视图,过滤器按预期工作..为什么它不适用于ngClass?什么是使用过滤值的正确方法ngClass(和其他类似的ngSrc等).
我的桌子风格非常好.
{抱歉链接不再工作}
我不得不添加sClass,以便新行(由fnAddData添加)获得正确的类.
不幸的是,这会破坏我的布局,因为这些类也被添加到我的表格标题单元格中!
{抱歉链接不再工作}
如何配置sClass仅适用于TBODY单元?
澄清:
var rolesTable = $('#roles').dataTable({
"aoColumns": [
{ "mDataProp": "id", "sClass": "avo-lime-h avo-heading-white" },
{ "mDataProp": "name", "sClass": "avo-light" },
{ "mDataProp": "module", "sClass": "avo-light" },
{ "mDataProp": "description", "sClass": "avo-light" },
{ "mDataProp": null, "bSearchable": false, "bSortable": false,
"sDefaultContent": '<button type="button" name="add" class="btn"><i class="icon-plus icon-white"></i></button>' },
],
}); // end od dataTable
Run Code Online (Sandbox Code Playgroud)
这样我打电话的时候
rolesTable.fnAddData( {
"id": 10,
"name": "testname",
"module": "testmodule",
"description": "testdescription"
} );
Run Code Online (Sandbox Code Playgroud)
然后添加的行看起来像这样:
<tr>
<td class="avo-lime-h avo-heading-white">10</td>
<td class="avo-light">testname</td>
<td …Run Code Online (Sandbox Code Playgroud) 我有OneToMany关系中的实体:
预测 - >有很多 - >砖块
我为Resources/config/serializer/Entity.xxx.ymlxxx是实体名称的每个人创建了序列化映射.
每个实体都将排除策略设置为ALL,并且其中一些属性被公开,例如:
Acme\ForecastBundle\Entity\Forecast:
exclusion_policy: ALL
xml_root_name: forecast
properties:
id:
expose: true
type: integer
regionUid:
expose: true
type: string
description:
expose: true
type: string
bricks:
expose: true
type: array<Acme\ForecastBundle\Entity\Brick>
xml_list:
inline: true
entry_name: brick
Run Code Online (Sandbox Code Playgroud)
在我的模板中,我{{ forecast|serialize|raw }}得到了:
预测 - >正如我所料 - >只有暴露的字段被序列化
砖块集合 - >所有属性都被序列化 - >似乎我Entity.Brick.yml被忽略了......为什么?
在砖块我只有ID和名称暴露..但在序列化输出我有所有属性(created_at,updated_at ..等等)..为什么?它们应该被"exclusion_policy:ALL"排除在外.似乎没有使用嵌套集合的配置.
Acme\ForecastBundle\Entity\Brick:
exclusion_policy: ALL
xml_root_name: brick
properties:
id:
expose: true
type: integer
name:
expose: true
type: string
Run Code Online (Sandbox Code Playgroud)
编辑:
是的,我在.yml配置中的每次更改后都清除了缓存
在提出一些建议之后,我将@ExclusionPolicy("ALL")注释添加到Brick类和@Expose on …
在构建Web应用程序时,我们经常会有与数据库条目相关联的文件,例如:我们有一个user表,每个类别都有一个avatar字段,该字段保存相关图像的路径.
为了确保文件名中没有冲突,我们可以:
ID.jpg; 那条路就是/user-avatars/ID.jpg/user-avatars/ID/original_filename.jpg其中ID是users唯一的ID号
从应用程序逻辑的角度来看,两者都是完全有效的.
但从文件系统性能的角度来看哪一个会更好?我们必须记住,category条目的数量可能非常高(数百万).
目录可以容纳多个子目录是否有限制?
# Ember : 1.4.0
# Ember Data : 1.0.0-beta.7+canary.b45e23ba
Run Code Online (Sandbox Code Playgroud)
我简化了我的用例,使问题更容易理解和更好.假设我们有3种型号:Country,Region和Area:
Country:
- id: DS.attr('number')
- name: DS.attr('string')
- regions: DS.hasMany('region')
Region:
- id: DS.attr('number')
- name: DS.attr('string')
- country: DS.belongsTo('country')
- areas: DS.hasMany('area')
Area:
- id: DS.attr('number')
- name: DS.attr('string')
- region: DS.belongsTo('region')
Run Code Online (Sandbox Code Playgroud)
Route的模型钩子应该返回一个对象数组.像这样:
注意:缩进只是为了使示例更具可读性.
Country I
Region A
Area 1
Area 2
Region B
Area 3
Country II
Region C
Area 4
Country III
Region D
Area …Run Code Online (Sandbox Code Playgroud) 两个实体GalleryAlbum和GalleryImage具有OneToMany/ManyToOne关系:
One GalleryAlbum ==== can have ====> Many GalleryImage
Many GalleryImage === can be in ===> One GalleryAlbum
(以下来源)
问题是什么?
将文件添加(上传)到GalleryAlbum
$ EM->坚持($专辑)
$ EM->齐平()
对于每个上传的文件,GalleryAlbum类会创建一个新的GalleryImage实体并将其添加到$ images
我的ECHO/EXIT测试未显示(未触发GalleryImage的名为preUpload的prePersist/preUpdate事件回调函数!)
我的新图像没有保存到数据库中?为什么?
奇怪的是什么! 如果我做:
添加(上传)文件
$ EM->坚持($专辑)
$ EM->齐平()
再次$ em-> flush()
显示我的ECHO/EXIT测试(触发了GalleryImage的名为preUpload的prePersist/preUpdate事件回调函数!)
(如果我删除echo/exit)我的新GalleryImages现在已保存!
为什么?
为什么在flush()一次时从不触发preUpload,而在flush()两次时触发preUpload?
#src GalleryAlbum.php
/**
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
* @ORM\Table(name="gallery_album")
*/
class GalleryAlbum
{
// some properties like id, name, description, etc
/**
* @ORM\OneToMany(targetEntity="GalleryImage", mappedBy="parent")
*/
protected $images;
/* Files container. Used … 我想要显示类似的东西:
案例1:"以USER身份登录"
@ UserName [logout]
这里没问题,我只是这样做:
@ {{app.user.username}} [<a href="{{path("logout")}}">退出</a>]
案例2:"以ADMIN身份登录"
@ AdminName [logout]
同样适用于此:
@ {{app.user.username}} [<a href="{{path("logout")}}">退出</a>]
案例3:"以ADMIN模拟用户身份登录"
AdminName @ UserName [返回]
现在这是一个问题:
{{ ?? ..这里有什么.. ?? } {{app.user.username}} [<a href="{{(app.request.getRequestUri~'?_switch_user=_exit')}}">返回</a>]
这是我所知道的唯一解决方案......似乎有很多代码用于显示用户名的sipmle:/
{# iterating through user roles to find ROLE_PREVIOUS_ADMIN #}
{% for role in app.security.token.roles %}
{% if role.source is defined %}
{{ role.source.user.username }}
{% endif %}
{% endfor %}
@ {{ app.user.username }} [ <a href="{{ (app.request.getRequestUri ~ '?_switch_user=_exit') }}">return</a> ]
Run Code Online (Sandbox Code Playgroud)
还有其他方法吗?我需要一个纯TWIG解决方案 - >这应该是我的主要模板模板的一部分(由所有其他模板扩展) …
考虑这个模型:
Grandparent
parents: DS.hasMany('parent')
Parent:
grandparent: DS.belongsTo('grandparent')
children: DS.hasMany('child')
Child:
parent: DS.belongsTo('parent')
Run Code Online (Sandbox Code Playgroud)
我想一个计算的属性添加children到Grandparent模型,其中我希望集合Child模型(Grandparent.children =合并的每个Grandparent.parents.children).
怎么做?
对于此示例数据:
Grandparent { id: 0, parents: [0, 1] }
Parent { id: 0, grandparent: 0, children: [0] }
Parent { id: 1, grandparent: 0, children: [1,2] }
Child { id: 0, parent: 0 }
Child { id: 1, parent: 1 }
Child { id: 2, parent: 1 }
Run Code Online (Sandbox Code Playgroud)
我想要Grandparent.get('children')带有ids [0,1,2]的孩子.
编辑:
App.Grandparent.reopen({
grandchildren: function(){
var result = …Run Code Online (Sandbox Code Playgroud) symfony ×4
javascript ×3
collections ×2
ember-data ×2
ember.js ×2
entity ×2
angularjs ×1
datatables ×1
doctrine-orm ×1
events ×1
file ×1
filesystems ×1
filter ×1
forms ×1
git ×1
php ×1
repository ×1
rsvp-promise ×1
twig ×1