我有一个Symfony的实体表格:
class MyType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
...
}
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'LogicielBundle\Entity\FichierGroup',
'intention' => $this->getName() . '_token'
));
}
Run Code Online (Sandbox Code Playgroud)
但是在POST_SUBMIT事件中,我想返回null(没有实体).我测试了这个,但没有工作:
$builder->addEventListener(FormEvents::POST_SUBMIT, function(FormEvent $event) {
.... my condition ...
$event->setData(null);
});
Run Code Online (Sandbox Code Playgroud)
你能帮助我吗 ?谢谢 :)
在我的PHPUnit测试方法中使用Doctrine和Symfony:
// Change username for user #1 (Sheriff Woody to Chuck Norris)
$form = $crawler->selectButton('Update')->form([
'user[username]' => 'Chuck Norris',
]);
$client->submit($form);
// Find user #1
$user = $em->getRepository(User::class)->find(1);
dump($user); // Username = "Sheriff Woody"
$user = $em->createQueryBuilder()
->from(User::class, 'user')
->andWhere('user.id = :userId')
->setParameter('userId', 1)
->select('
user
')
->getQuery()
->getOneOrNullResult()
;
dump($user); // Username = "Chuck Norris"
Run Code Online (Sandbox Code Playgroud)
为什么我的两种获取用户#1的方法返回不同的结果?
当我在互联网上搜索react-native优化/最佳实践(特别是FlatLists通常贪婪的优化/最佳实践)时,我总是找到不要使用箭头函数的建议<Component onPress={() => ... }。
示例1: https ://reactnative.dev/docs/optimizing-flatlist-configuration#avoid-anonymous-function-on-renderitem :
\n\n\n将 renderItem 函数移出到 render 函数的外部,这样每次调用 render 函数时它就不会重新创建自己。(...)
\n
示例 2: https: //blog.codemagic.io/improve-react-native-app-performance/:
\n\n\n避免箭头函数:箭头函数是浪费重新渲染的常见罪魁祸首。不要\xe2\x80\x99t 在函数中使用箭头函数作为回调来渲染视图 (...)
\n
示例 3: https: //medium.com/wix-engineering/dealing-with-performance-issues-in-react-native-b181d0012cfa:
\n\n\n箭头函数是浪费重新渲染的另一个常见嫌疑点。不要在渲染函数中使用箭头函数作为回调(例如单击/点击)(...)
\n
据我了解,建议不要使用箭头功能(尤其是在onPress按钮 和中FlatList),并尽可能将组件放在渲染之外。
良好实践示例:
\nconst IndexScreen = () => { \n const onPress = () => console.log(\'PRESS, change state, etc...\')\n\n return (\n <>\n <Button\n …Run Code Online (Sandbox Code Playgroud) 我已经安装了Wkhtmltopdf,当我执行他“/var/chroot/wkhtmltox-jessie-amd64:权限被拒绝”时出现此错误。我在 Google 中搜索,但我还没有找到该怎么做...剧目有这个权限“drwxr-xr-x root root”,我在网络服务器(apache)和 Symfony 中执行他。
错误 :
退出状态代码“126”表示出了问题:stderr:“sh:1:/var/chroot/wkhtmltox-jessie-amd64:权限被拒绝”stdout:“”
你能帮助我吗 ?
我在使用 React Native 和 flexbox 时遇到了一个奇怪的情况。
在这种情况下,我不明白为什么x按钮超出了它们的容器(cyan背景),尽管有 flexWrap。
我希望x按钮返回到青色容器内的行,如标题(但按钮a b c d必须保持在右侧,这样效果很好)。
https://codesandbox.io/s/lucid-dream-0q5yo?file=/src/App.js
class App extends Component {
render() {
return (
<View style={styles.container}>
<ListItem>
<ListItem.Content style={styles.content}>
<ListItem.Title>
My title My title My title My title My title My title My title My
title
</ListItem.Title>
<View style={styles.chart_container}>
<View style={styles.chart}></View>
<View style={styles.item_container}>
<Button title="x" />
<Button title="x" />
<Button title="x" />
<Button title="x" />
<Button title="x" />
<Button title="x" />
<Button …Run Code Online (Sandbox Code Playgroud) 这个简单的类返回
1) 警告为 App\Tests\Twig\GenerateTokenTest::testGenerateToken 指定的数据提供程序无效。数据集#0 无效。
class GenerateTokenTest extends TestCase
{
/**
* @dataProvider provideToken
*/
public function testGenerateToken(int $length): void
{
$token = GenerateToken::generate($length);
$this->assertTrue(true);
}
public function provideToken(): iterable
{
yield 8;
yield 16;
yield 29;
}
}
Run Code Online (Sandbox Code Playgroud)
你知道为什么吗 ?
对于react-navigation/native (5.9.4)和 iOS(在 iPhone 8 上测试),我无法使用createMaterialBottomTabNavigator() (5.3.15)和createMaterialTopTabNavigator() (5.3.15)。
当我使用这两个功能时,键盘不会在 iOS 上打开(或立即关闭)。这使得输入完全无法使用。
\n\n我重新创建了一个非常简单的模型。使用 Snack Expo,在 Android 上,一切正常,在 iOS 上,键盘无法打开:
\nhttps://snack.expo.io/xUeskyMm-
\n在 中/Navigator/BottomTabNavigator,您可以更改取消注释/注释代码:
const BottomTabNavigator = () => {\n return (\n <Tab.Navigator>\n {/*\n <Tab.Screen\n name="GymTopTab"\n component={GymTopTabNavigator}\n options={{\n tabBarLabel: "S\xc3\xa9ances",\n }}\n />\n */}\n <Tab.Screen\n name="TrainingStack"\n component={TrainingStackNavigator}\n options={{\n tabBarLabel: "S\xc3\xa9ances",\n }}\n />\n </Tab.Navigator>\n )\n}\nRun Code Online (Sandbox Code Playgroud)\n当我不使用时createMaterialTopTabNavigator()一切正常。createMaterialBottomTabNavigator()这就是为什么我认为当我和一起使用时会出现错误createMaterialTopTabNavigator()。但令我感到非常惊讶的是,如此基本的情况却造成了如此大的问题。
我刚刚设置了 Firebase Crashlitics,但看到了此错误:
致命异常:java.lang.UnsatisfiedLinkError找不到要加载的DSO:libhermes.so SoSource 0:com.facebook.soloader.ApkSoSource [root = /data/data/com.wololofit/lib-main flags = 1] SoSource 1 : com.facebook.soloader.DirectorySoSource[root = /data/app/~~DAa5QmzRi5oxpzp3KsccGQ==/com.wololofit-EEiD-rJZDFCbRjzPj4o-mQ==/lib/arm64 flags = 0] SoSource 2:com.facebook.soloader。 DirectorySoSource[root = /vendor/lib64 flags = 2] SoSource 3:com.facebook.soloader.DirectorySoSource[root = /system/lib64 flags = 2] 本机 lib 目录:/data/app/~~DAa5QmzRi5oxpzp3KsccGQ==/com. wololofit-EEiD-rJZDFCbRjzPj4o-mQ==/lib/arm64 结果:0
根据我的研究,此错误适用于某些不支持 Hermes 的设备:https://github.com/facebook/react-native/issues/29528
经常提出几种解决方案:
解决方案1.添加到android/app/build.gradle:
implementation 'com.facebook.soloader:soloader:0.9.0+'
Run Code Online (Sandbox Code Playgroud)
解决方案2.添加:
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
qaImplementation files(hermesPath + "hermes-release.aar")
stageImplementation files(hermesPath + "hermes-release.aar")
prodImplementation files(hermesPath + …Run Code Online (Sandbox Code Playgroud) 使用react native和flexbox,我不明白为什么文本在容器之外(橙色bakcground)?
<View style={styles.main_container}>
<View style={styles.infos_container}>
<View style={styles.info_item}>
<Text style={styles.info_name}>
Âge
</Text>
<Text style={styles.info_value}>
18
</Text>
</View>
<View style={styles.info_item}>
<Text style={styles.info_name}>
Médias publics
</Text>
<Text style={styles.info_value}>
2
</Text>
</View>
</View>
</View>
const styles = StyleSheet.create({
infos_container: {
backgroundColor: 'orange',
flex: 1,
flexDirection: 'row',
flexWrap: 'wrap',
padding: 5,
},
info_item: {
margin: 5,
alignItems: 'center',
},
info_name: {
color: '#6c757d',
fontSize: 11,
},
info_value: {
color: '#343a40',
},
})
Run Code Online (Sandbox Code Playgroud)
我只希望块styles.info_item是水平的橙色背景
在 javascript 和 React Native 中,我使用了一个 API 函数,它返回两个元素:results和error.
import { findAll as forumFindAll } from '../../Api/ForumApi'
const IndexScreen = () => {
const [results, error] = forumFindAll()
...
Run Code Online (Sandbox Code Playgroud)
我想重命名变量results并error在一行上(很像解构)。
类似的东西(但我知道它不起作用):
const [results as forumsResults, error as forumsError] = forumFindAll()
Run Code Online (Sandbox Code Playgroud) react-native ×6
reactjs ×3
symfony ×3
javascript ×2
php ×2
phpunit ×2
apache2 ×1
css ×1
debian ×1
doctrine ×1
flexbox ×1
wkhtmltopdf ×1